I\'m trying to make a server / client connection with sockets. But they will not close properly and I can\'t wrap my head around why.
I\'ve corre
you need socket.socket.setsockopt
, .i.e s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
Though the socket will be closed by the os when process ended, it is a good behavior to call close() explicitly.
However, after that, the local addr(local_ip, local_port) is not avaiable until 2 MSL(maximum segment lifetime)
has passed. Why? and what we can do? you can read these:
http://www.tcpipguide.com/free/t_TCPConnectionTermination-3.htm and http://www.unixguide.net/network/socketfaq/4.5.shtml
It will be difficult to me to post it more clear than they do :).