嘿嘿!
全部博文(140)
分类: LINUX
2010-05-07 16:36:51
As far as I know there is no way to forcibly close the socket outside of writing a better signal handler into your program, but there is a /proc file which controls how long the timeout takes. The file is
/proc/sys/net/ipv4/tcp_tw_recycle
and you can set the timeout to 1 second by doing this:
echo 1 > /proc/sys/net/ipv4/tcp_tw_recycle
However, this page contains a warning about possible reliability issues when setting this variable.
There is also a related file
/proc/sys/net/ipv4/tcp_tw_reuse
which controls whether TIME_WAIT sockets can be reused (presumably without any timeout).
Incidentally, the kernel documentation warns you not to change either of these values without 'advice/requests of technical experts'. Which I am not.
The program must have been written to attempt a binding to port 49200 and then increment by 1 if the port is already in use. Therefore, if you have control of the source code, you could change this behaviour to wait a few seconds and try again on the same port, instead of incrementing.