I've been spending some time on building a server; One of the situations I got in is that I have a streamingsocket (TCP) listener that accepts incoming connections. I know that under water a port will be bound to another port number so new connections can be made on the listening port.
So I tried some functions like getBoundedPort() in order to get the new port number that the server pushed the new connection onto. However, if for instance my listener listens to port 2345, then the bound port will still return 2345. I am not entirely sure why, since if this was really the case, the server couldn't accept new connections due the port being in use.
Generally, I am thinking this problem occurs because the newly bound port number isn't updated internally or the information isn't available.
This situation arises on at least Windows 7 64-bit. I do not know what your experiences are with this.
I'd like to know how the new port number can be retrieved.