kannan@cerc.wvu.wvnet.edu (R. Kannan) (09/22/89)
Hai We would like to seek the advise on two issues: Problem 1: What is the bext way to handle errno 61 => ETIMEDOUT, error => connection timed out. At the present we are closing the socket and reopening if errno == 61. This also led to errno 48 and 54 which are #define EADDRINUSE 48 /* Address already in use */ #define ECONNRESET 54 /* Connection reset by peer */ What are the several options available if one desires to send the message anyway! Simple sample code would help. Problem 2: "gethostid" returns a "long", the id of the processor. "gethostbyname" returns a pointer to "struct hostent", with two fields of relevance => "h_addr" and "h_length" After an "accept" call, the address of the peer is placed in the sockaddr_in.sin_addr.s_addr field. 1. Are the results returned by gethostid, gethostbyname and accept calls compatible. 2. What are the necessary htonl, ntohs conversion required. 3. Atleast in the AF_INET domain, can one assume that the host length will be == sizeof(long or u_long)? Simple sample code would help. Thank you very much for your time. --kannan
hwajin@wrs.wrs.com (Hwajin Bae) (09/25/89)
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
hwajin@wrs.wrs.com (Hwajin Bae) (09/25/89)
In article <764@wrs.wrs.com> hwajin@wrs.wrs.com (Hwajin Bae) writes: >numbers to need to be converted using htonl() when connecting to the remote I meant to say htons() instead of htonl() here. -- Hwajin Bae Wind River Systems, Emeryville, CA