[ee122] gathering info with random unused ports (sin_port == 0)

vern at cs.berkeley.edu vern at cs.berkeley.edu
Sun Nov 25 23:16:28 PST 2007


> From there, though, how do I figure out what port the kernel chose? Did it
> overwrite the value? Is there a function analogous to getpeername() where
> the struct gets filled in with info?

Yes, see getsockname().

> I need to advertise the second (incoming on the initiator side) socket to
> the reciever if he is intending to send things back, but I can't find where
> to get my random port number for the socket I'm using.

Keep in mind that Project 2 no longer requires establishing bidirectional
communication, so you don't in fact need to set up this sort of rendezvous.

		Vern


More information about the ee122 mailing list