How to handle connection time outs + host address compatibility ...

Hwajin Bae hwajin at wrs.wrs.com
Mon Sep 25 11:29:19 AEST 1989


If your network is extremely congested and packets are not getting through
there is really no way to prevent ETIMEOUT errors from happening after a lot of
failed retransmissions.  Using KEEP_ALIVE will probably make this worse in you 
case since it will generate more packet transmissions and the KEEP_ALIVE timer
can also generate ETIMEOUT error when it expires.  However, EADDRINUSE
error is mainly due to the fact that your side of the connection has been
just dropped and the kernel socket data structure has not yet been freed up.
In order to get around this you can use REUSEADDR option on the socket
so that the bind call will not return EADDRINUSE error.  Pretty much the only
thing you can do when the connection is reset by the peer is to try to
re-establish the connection.

The gethostid() returns unique ID that is not necessarily related to the
Internet address of your machine (in fact, some implementations return magic
machine ID encoded in PROM's).  Internet addresses in their usual unsigned
long representations need not be converted using htonl() in general since
they are assumed to be always represented in big endian format.  The port
numbers to need to be converted using htonl() when connecting to the remote
machine.

-- 
Hwajin Bae
Wind River Systems, Emeryville, CA



More information about the Comp.unix.wizards mailing list