<div>So Beej told me that if I want to bind a socket to a random port number, I can just set the sAddr_in.port to 0. Then the kernel will decide which port that is.</div>
<div>&nbsp;</div>
<div>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?</div>
<div>&nbsp;</div>
<div>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&#39;t find where to get my random port number for the socket I&#39;m using.</div>

<div>&nbsp;</div>
<div>Thanks,</div>
<div>Rick</div>