Forcing TCP sockets to close ?

John Jannotti jj at lcs.mit.edu
Sat May 8 20:20:59 EDT 1999


The TCP standard mandates that sockets stay in CLOSE_WAIT for about 2
minutes after close in order to avoid reusing that port and causing
confusion between packets from the old and new connection.  If you
want to avoid this "feature", use something like this:

int  i = 1;
if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &i, sizeof(i)) < 0)
    perror("setsockopt");

before you bind s.

  jj

-
Subcription/unsubscription/info requests: send e-mail with
"subscribe", "unsubscribe", or "info" on the first line of the
message body to discuss-request at blu.org (Subject line is ignored).



More information about the Discuss mailing list