Mailing List
Home
Forum Home
Linux - General Red Hat Linux discussion list
Enterprise Linux 3 - Discussion of Red Hat Enterprise Linux 3 (Taroon)
Installation - Getting started with Red Hat Linux
Red Hat Linux 9 - Discussion of Red Hat Linux 9 (Shrike)
Red Hat Linux 7.3 - Discussion of Red Hat Linux 7.3 (Valhalla)
Red Hat Linux 7.2 - Discussion of Red Hat Linux 7.2 (Enigma)
Apache Web Server
Oracle database, Microsoft SQL server ...
Subjects
application/x mplayer2 plugin
RPM error: db4 error(16) from dbenv >remove: Device or resource
   busy
Command stream end of file while reading
X Windows problem (xauth)
Upgrading openoffice 1 1 rpm
FTP: connection refused
FTP: connection refused
mount: /dev/cdrom: is not a valid block device
Dell Precision 650, RedHat 9, no sound
how to trace the cause resulting in the crash of bind server
Virus on the list
UNINSTALL RPM MYSQL
usb pen drives: mounting as a user
broadcom network interface
make mrproper
sendmail configuration on redhat
Couldn 't open PID file /var/run/named/named pid Permission denied
Promise 378 controller
kernel 2 6 and /dev/sound/mixer not found
Problem using up2date
mrtg step by step howto/configuration for a newbie?
Compiling and Installing Kernel 2 6
Can 't locate module ppp0, can 't locate module ppp compress 21
HOW I CAN MAKE BOOTABLE FLOPPY DISKET
Lotus Notes under Wine
/etc/security/limits conf question
Intel E/1000 driver
Command stream end of file while reading
rpm database corrupt
qla2300 modules
 
Search:  
Power your search with and, or, +, -, or "some phrase" operators.
setsockopt problems

setsockopt problems

2004-02-10       - By Brian T. Brunner

 Back
Reply:     1     2  

what I want: sockets on system1 to realize the other end on system2 is dead, so
select() returns an exception condition on the socket to the dead system. I
want this to happen within about 5 seconds of yanking the network or AC cable
to System2.

What I get: system1 'realizes' system2 is unplugged about 2 minutes after the
fact.

What I do: setsockopts on each socket opened between system1 & 2 as follows:

int SetSocketOptions(int fd)
{
   int errval = 0;
   if (fd >= 0)
   {
  int val = 1;
  int step = 0;
  struct linger myLinger = {1,0}; // wait 0 seconds for data to drain from the
OutQ before returning from close(); cause RST/ABORT on this socket.

#define MAYBEDO(a,b,c,d,e,f,g) { if ((a) == 0) {(a) |= setsockopt(c,d,e,f,g); b
++;}}

  MAYBEDO(errval,step,fd,SOL_SOCKET,SO_LINGER,&myLinger,sizeof(myLinger));
  // man ip: A  TCP local socket address that has been bound is unavailable for
  // some time after closing, unless the SO_REUSEADDR flag has been set.  Care
  // should be taken when using this flag as it makes TCP less reliable.
  MAYBEDO(errval,step,fd,SOL_SOCKET,SO_REUSEADDR,&val,sizeof(val));
  val = 1;
  MAYBEDO(errval,step,fd,SOL_SOCKET,SO_KEEPALIVE,&val,sizeof(val));
  // Cause 2 second wait before first keepalive, a 2 second interval between
them, and a max count of 2 before giving up on the socket.
  val = 2;
  MAYBEDO(errval,step,fd,SOL_TCP,TCP_KEEPINTVL,&val,sizeof(val));
  MAYBEDO(errval,step,fd,SOL_TCP,TCP_KEEPIDLE,&val,sizeof(val));
  MAYBEDO(errval,step,fd,SOL_TCP,TCP_KEEPCNT,&val,sizeof(val));
  // Do not delay transmission to coalesce packets (Nagle Algorithm); each
should go promptly by itself.
  MAYBEDO(errval,step,fd,IPPROTO_TCP, TCP_NODELAY,&val,sizeof(val));
  if (errval)
  {
     printf("setsockopt(%d) returned error %s step %d ", fd, strerror(errno),
step);
  }
   }
   else errval = fd;    // any non-zero return will do.
   return errval;
}


Brian Brunner
brian.t.brunner@(protected)
(610)796-5838



**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept
for the presence of computer viruses.

www.hubbell.com - Hubbell Incorporated
**********************************************************************


--
Shrike-list mailing list
Shrike-list@(protected)
https://www.redhat.com/mailman/listinfo/shrike-list



Earn $52 per hosting referral at Lunarpages.