Xref: utzoo comp.unix.questions:16544 comp.protocols.tcp-ip:8433 comp.unix.wizards:18326 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!purdue!ames!pacbell!rtech!wrs!hwajin From: hwajin@wrs.wrs.com (Hwajin Bae) Newsgroups: comp.unix.questions,comp.protocols.tcp-ip,comp.unix.wizards Subject: Re: How to handle connection time outs + host address compatibility ... Keywords: socket, ETIMEDOUT, RESET BY PEER + gethostid, gethostbyname .... Message-ID: <764@wrs.wrs.com> Date: 25 Sep 89 01:29:19 GMT References: <237@cerc.wvu.wvnet.edu.edu> Reply-To: hwajin@wrs.wrs.com (Hwajin Bae) Organization: Wind River Systems, Emeryville, CA Lines: 23 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