SUMMARY: Solaris Socket Question

From: Jim Murff (jmurff@orincon.com)
Date: Wed Mar 05 1997 - 15:58:14 CST


Hi;

Sorry for the delay on this but I wanted to test it out first. Got great
advice and help on this. Thanks!!
Solution was multi-part with several options:
Using ndd
        ndd /dev/tcp tcp_close_wait_interval
It can be adjusted with:
        ndd -set /dev/tcp tcp_close_wait_interval 60000
This would set it to 1 minute.
In the server, immediately after your call to socket, you need to set the
SO_REUSEADDR option with setsockopt. ( the SO_LINGER Otpion can be adjusted
too.)
The only s
disagreement seems to be whether you can set this parameter in the
/etc/system file. I didn't mess with it, I instead added it to one
of the rc scripts.

Original message and several useful responses attached.

Thanks to :
        Davin Milun <milun@cs.Buffalo.EDU>
        dunbar@cyclone.mitre.org (Brian E. Dunbar)
        cathie@aisg.com (Cathie Baier)
        seanw@amgen.com
        James.E.Coby.Jr@cdc.com (James Coby)
        Mike Youngberg <mikey@synacom.com>
        Ric Anderson <ric@rtd.com>
        Jacques Rall <jacques.rall@za.eds.com>
        Casper Dik <casper@holland.Sun.COM>
        Stephen Harris <sweh@mpn.com>
        Boyko, Steve" <SBoyko@nbpower.com>
        poffen@San-Jose.ate.slb.com (Russ Poffenberger)

-Jim
-----------------------------------------------------------------------------
    Jim Murff, Orincon (murff@orincon.com) Voice # (619)455-5530 x359
    Head Unix Geek Fax # (619)453-9274

                      Be obscure clearly. -E.B White
-----------------------------------------------------------------------------
-------------------------------- ORIGINAL MESSAGE ---------------------------
Hi All;

A user of mine wrote some IPC (TCP/IP sockets) software a while
back. It was originally developed under Sun OS but later converted to
Solaris. Since then it doesn't work quite right: when the program
terminates normally, and they close all the sockets before exiting, they
have to wait about five minutes before they can run the program again
because it appears that the sockets are still in use. After 5
minutes the OS times the sockets out and they are again available for the
program to use. Under Sun OS the program could be re-run immediately.
What needs to be done differently so that the Solaris TCP/IP sockets are
free immediately? is there a /etc/system variable to control this timeout?
I checked the Solaris porting and OS FAQ's but they don't seem to mention
any problems. Also I can't seem to see any patches that might be helpful.
Any help would be greatly appreciated.

-Jim Murff
-----------------------------------------------------------------------------
    Jim Murff, Orincon (murff@orincon.com) Voice # (619)455-5530 x359
    Head Unix Geek Fax # (619)453-9274

                      Be obscure clearly. -E.B White
-----------------------------------------------------------------------------
----- End Included Message -----
Subject: Re: Solaris Socket Question

Jim,

Check out:
ndd /dev/tcp tcp_close_wait_interval

This is the time spent in TIME_WAIT on a socket after a connection closes.
The default is 240000ms (4 minutes).

It can be adjusted with:
ndd -set /dev/tcp tcp_close_wait_interval 60000

This would set it to 1 minute. This would need to be in one of your
start up scripts as this is not controlled by /etc/system.

I don't know if this would impact other things on your system, but it's
worth a try. BTW, I found this information in W. Richard Steven's book,
_TCP/IP_Illustrated,_Volume_1:_The_Protocols_

Good Luck,
Cathie Baier
Systems Engineer/Instructor
Advanced Information Systems Group, Inc.
7900 Xerxes Ave. S.
Suite 180
Bloomington, MN 55431
(612) 896-5700
-------------------------------------------------------------------------------
 
In your server, immediately after your call to socket, you need to set the
SO_REUSEADDR option with setsockopt.

 int yes=1;

 if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *)&yes, sizeof(yes))<0)
      {
      fprintf(stderr,"setsockopt SO_REUSEADDR failed\n");
      perror(progname);
      exit(1);
      }

Davin.

-- 
Davin Milun    Internet:  milun@cs.Buffalo.EDU     milun@acm.org
               Fax:       (716) 645-3464
               WWW:       http://www.cs.buffalo.edu/~milun/

--------------------------------------------------------------------------------



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:11:48 CDT