Path: utzoo!attcan!uunet!cs.utexas.edu!samsung!usc!ucsd!ucbvax!ulysses!ulysses.att.com!smb From: smb@ulysses.att.com (Steven Bellovin) Newsgroups: comp.protocols.tcp-ip Subject: Re: How long before I can reopen a closed socket? Message-ID: <13143@ulysses.att.com> Date: 15 Jun 90 20:41:14 GMT References: <4847@litle.litle.COM> <515@seqp4.UUCP> Sender: netnews@ulysses.att.com Lines: 25 In article <515@seqp4.UUCP>, markr@seqp4.ORG (Mark Roddy) writes: > The solution is to not use the well known address for the connection - > TCP allows you to accept a connection on a different port address than > the destination address in the connection request. > > This is the mechanism used by most *nix TCP/IP services. > > The well-known address is always available to service the > next incoming connection request. No, that's not quite correct. A TCP connection is defined by the 4-tuple . Servers define the first two parts -- on Berkeley-derived systems, via the bind() call. When a client connects, a connection is instantiated with a fixed pair of values for . The server's partial connection -- or rather, the under-specified TCB for its passive open -- can still exist; that's an implementation issue. What happens on Berkeley-derived systems is that you get a new file descriptor in the server for each connection; the port numbers don't change. However, the kernel will not let you bind even a server port if any TCBs exist with the same portion, even if all of the others have filled in. You can override this via setsockopt() with the SO_REUSEADDR option. Inetd does exactly that.