Is there a portable way for a running process to discover what
local port number has been allocated by the kernel to a socket?
I don't believe using netstat is portable since it looks up the
/proc file system which seems to differ between unices.
For the server side of a socket connection one can look at the value
in sin_port of the sockaddr structure. However for the client side,
where this is set to the server side port number to make the correct
connection to the server, it is this (remote) port number which is held
in sin_port rather than the local port number.
Chris Willing Ph: (61-2) 9351 1893 (| 3005)
Vislab, A28 Fax: (61-2) 9351 1880 (| 7726)
NSW 2006 Australia http://www.vislab.usyd.edu.au/staff/chris/