tcp timout

I am led to understand that there when a port is bound for a tcp connection...once that connection is closed there is a timeout period before that port can be reused ... and the software I am using shows that. How long is this timeout - what affects it and is there anyway to reuce the timeout?

The timeout depends on your kernel. There is an RFC standard which specifies the maximum TIME_WAIT as (I believe) 4 minutes. Note that is a maximum, most times it will be much less than that. The most I have seen under Linux is 2 minutes. YMMV depending on the vendor.

Okay cool - so no hard and fast rule....especially as I'm working across a number of platforms. I have since noticed that closing the connection has a much shorter time out thank a kill. So I'm happy enough with the delay now. Thanks:)

Yes, if you close the connection cleanly you should have no (noticeable) TIME_WAIT delay. If you 'kill' the process without a clean shutdown, or if it crashes you will generally get the delay.

The TIME_WAIT state follows the termination of a TCP connection and it lasts for double the time MSL (Maximum Segment Lifetime).
The MSL is the time required for a segment to travel from the source to the destnation. The TIME_WAIT state varies from two to four minutes, usually. If you want to reduce this time period you have to set the SO_LINGER socket option and set the l_linger member of the struct linger to zero. This will cause TCP to send a RST message instead of the normal termination messages, when the close system call is executed.
Allthough that will abort the TIME_WAIT state it is not a good idea to do so, because there is the possibility to receive a segment from the previous connection.

Wonderful! developer.

Just as the descripition achieved by Mr. W.Richard Stevens in his famous "UNIX Network programming Volume 1", the TIME_WAIT state is friendly to all of us. So obviously avoiding this port state is not a wise choice!