Notes |c|Quality|emacs|vi|IMAP|unix|NIS|cde|perl|html|javascript|java|netscape

Handy references/tutorials

socket TIME_WAIT info

Mail Thread Index cleaning up TIME_WAIT states
http://www.sunsite.auc.dk/RFC/rfc/ RFC HyperText Archive, search RFCs for TIME_WAIT
RFC 1337 - TIME-WAIT Assassination Hazards in TCP
RFC 1122 - Requirements for Internet Hosts -- Communication Layers
RFC 793 - Transmission Control Protocol
RFC 1323 - TCP Extensions for High Performance
RFC 916 - RELIABLE ASYNCHRONOUS TRANSFER PROTOCOL (RATP)
RFC 1339 - Remote Mail Checking Protocol
stuck in TIME_WAIT, winsock mailing list Try setting SO_REUSEADR before closing the socket.
setting SO_REUSEADDR, SO_REUSEPORT and SO_LINGER


When this is done in the server NFMSrv ... i.e. in the OMC code?
The sockets don't linger in time_wait after client shutdown.
NFMSim sockets are not the problem => setting them there won't help.

NFMSim         ascOutput
--------------------------------------
socket         socket
               set REUSEADDR/PORT LINGER
               bind(6543)
connect------->accept
recv   <-------send
 ..             ..
shutdown       shutdown, TIME_WAIT exits because of REUSE* and LINGER

NFMSim shutdown before ascOutput => no problems, no TIME_WAIT
ascOutput shutdown first => TIME_WAIT without LINGER

   int nAllowReuse = 1;
   if (setsockopt(nfmSocketFd, SOL_SOCKET, SO_REUSEADDR, 
                         (char*)&nAllowReuse, sizeof(nAllowReuse)) <0 )
     {
       cerr << "NFMSim:setHost:ERROR: could not set socket to reuse addr." << endl;
     }

   if (setsockopt(nfmSocketFd, SOL_SOCKET, SO_REUSEPORT, 
                         (char*)&nAllowReuse, sizeof(nAllowReuse)) <0 )
     {
       cerr << "NFMSim:setHost:ERROR: could not set socket to reuse port." << endl;
     }

   linger lingerSet;
   lingerSet.l_onoff = 0;
   lingerSet.l_linger = 0;
   // set server to allow reuse of socket port
   if (setsockopt(nfmSocketFd, SOL_SOCKET, SO_LINGER, 
                         (char*)&lingerSet, sizeof(lingerSet)) <0 )
     {
       cerr << "NFMSim:setHost:ERROR: could not set socket to linger." << endl;
     }

Debugging

Use netstat and grep for the connecting hostname or port (if you're using a fixed port).

ypcat hosts |grep hostname
arp -a |grep hostname
   ip.add.re.ss   hostname

netstat
NFMSrv --- nothing
NFMSim ---
tcp        0      0  hostname.6543          hostname.1641          ESTABLISHED
tcp        0      0  hostname.1641          hostname.6543          ESTABLISHED
ctrlCNFMSrv

$  netstat |grep 6543
tcp        0      0  hostname.6543          hostname.1641          FIN_WAIT_2
tcp        0      0  hostname.1641          hostname.6543          CLOSE_WAIT

quit NFMSim
$ netstat |grep 6543
tcp        0      0  hostname.6543          hostname.1641          TIME_WAIT

run NFMSim, connection fails ... but exits TIME_WAIT ... or timeouts?

quit NFMSim 1st, then NFMSrv and all is fine.

Fun with browsers: monitoring the http server side while downloading pages. see which versions of browsers have bad socket behaviour. basically: netscape 4.7 on solaris was good, netscape 4.6 on winNT bad, opera 3.60 on winNT good.

Notes |c|Quality|emacs|vi|IMAP|unix|NIS|cde|perl|html|javascript|java|netscape


back to home