The best way to get a connection from TIME_WAIT (surprisingly) is to wait :-)
How TCP / IP Works A session is identified by a tuple (sourceIP, sourcePort, destIP, destPort, protocol) , and the reason you cannot reuse it is because there might be packets still on the network.
The TIME_WAIT state is typically two times the maximum packet life, and you should not bother with it, as this may cause packets to be displayed from the previous session (which will ruin your current session).
Ideally, you need to connect from a different source port, after which you can immediately open a session.
Another thing you must observe is badly closed sessions. I always subscribed to the recommendation that the client should close the session (and completely close it). This minimizes the opportunity for long-lived half-closed sessions.
source share