finding my port number

finding my port number

Post by Dave Goodwi » Fri, 14 Jul 2000 04:00:00



Hi

I know that when bind()ing I can pass a sockaddr struct with the sin_port
field set to 0, so that the OS can choose a suitable free port for me. How
I can I then find out what port was chosen?

cheers

dave

 
 
 

finding my port number

Post by Russ Allber » Sun, 16 Jul 2000 04:00:00



> I know that when bind()ing I can pass a sockaddr struct with the
> sin_port field set to 0, so that the OS can choose a suitable free port
> for me. How I can I then find out what port was chosen?

Call getsockname on the open file descriptor.

--


 
 
 

finding my port number

Post by mike burrel » Mon, 17 Jul 2000 04:00:00



> I know that when bind()ing I can pass a sockaddr struct with the sin_port
> field set to 0, so that the OS can choose a suitable free port for me. How
> I can I then find out what port was chosen?

try getsockname().

--
             /"\                                m i k e    b u r r e l l

              X        AGAINST HTML MAIL,
             / \      AND NEWS TOO, dammit