I\'m binding a client TCP socket to a specific local port. To handle the situation where the socket remains in TIME_WAIT state for some time, I use
TIME_WAIT
Be careful in binding the local port NOT to use the loopback address "127.0.0.1", or you will get connection timeouts. Better not to populate the sa_loc.sin_addr.s_addr at all - that works just fine.