From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <96075316706686.tru64-unix-managers.marc@archive.invalid> From: bouti () acri ! fr (Mourad Bouti (A ! S ! )) Date: Tue, 31 Jan 1995 09:54:33 +0000 To: tru64-unix-managers Subject: TCP pb X-MARC-Message: https://marc.info/?l=tru64-unix-managers&m=96075316706686 ----- Begin Included Message ----- >From dehaudt@acri.fr Mon Jan 30 09:45:37 1995 X-Authentication-Warning: soft204: Host localhost didn't use HELO protocol To: os@acri.fr Subject: TCP pb Date: Mon, 30 Jan 95 09:45:31 +0100 From: "Christophe DEHAUDT" X-Mts: smtp Content-Length: 4760 PROBLEM: We have got a TCP problem with the DEC/OSF3.0 that didn't have with DEC/OSF1.3: We have 2 processes which communicate with 1 socket but only in one way. (We have shutdowned the way that is not used) We use the connection for a while, and don't use it for (perhaps) a long time (ex: 4 hours) --------- --------- | | | | | P1 |<--------------------| P2 | | rcver | | sender| | | | | --------- --------- shutdown OUT shutdown IN set keep alive With this configuration, we receive a timeout error (ETIMEDOUT) after 2 hours of non use when running on a 3.0 version (this was not happening on the 1.3). In annexes, there are 2 source codes which reproduce the problem. rmq: Even if the sender don't set the KEEPALIVE option, the rcver will die after 2 hours of inactivity. CONCLUSION: Either we use the shutdown functionality in a bad way, but no particular specifications have been found to prevent this use, or there is a miss in the kernel for this case. ANNEXES: /**************************** SENDER ****************************/ #include #include #include #include #include #define PORT 5432 void main(argc, argv) int argc; char *argv[]; { register int si, out; struct sockaddr_in inaddr, claddr; int clilen; int yes = 1; if ((si = socket(AF_INET, SOCK_STREAM, 0)) < 0) { exit(errno); } /* initialize inet addr */ bzero((char *)&inaddr, sizeof(inaddr)); inaddr.sin_family = AF_INET; inaddr.sin_addr.s_addr = htonl(INADDR_ANY); inaddr.sin_port = htons(PORT); if (setsockopt(si, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) < 0) { exit(errno); } if (bind(si, &inaddr, sizeof(inaddr)) < 0) { exit(errno); } listen(si, 5); printf("Waiting for connection ...\n"); if ((out = accept(si, &claddr, &clilen)) < 0) { exit(errno); } printf("Connection established.\n"); if (shutdown(out, 0) < 0) { exit(errno); } if (setsockopt(out, SOL_SOCKET, SO_KEEPALIVE, (char *)&yes, sizeof(int)) < 0) { fprintf(stdout, "set SO_KEEPALIVE failed"); exit(-1); } write(out, &yes, 8); for (;;) sleep(100); /* wait for the crash of the rcver */ } /************************* END SENDER ****************************/ /**************************** RCVER ******************************/ #include #include #include #include #include #include #include #include #include #define PORT 5432 #define CRASH_TIME 7200 #define TIME_INCR 1 void main(argc, argv) int argc; char *argv[]; { register int in; struct sockaddr_in inaddr; int yes = 1; int pid; fd_set inmask; int maxfd, nfound; struct timeval timeout; int crashdate = CRASH_TIME; char buffer[8]; /* initialize inet addr */ bzero((char *)&inaddr, sizeof(inaddr)); inaddr.sin_family = AF_INET; inaddr.sin_addr.s_addr = htonl(INADDR_ANY); inaddr.sin_port = htons(PORT); if ((in = socket(AF_INET, SOCK_STREAM, 0)) < 0) { fprintf(stdout,"socket error"); exit(-1); } if (connect(in, &inaddr, sizeof(inaddr)) < 0) { fprintf(stdout, "connect failed, exit...\n"); exit(-1); } if (shutdown(in, 1)) { fprintf(stdout, "error during shutdown\n"); exit(-1); } /* the sender send one byte to test it is working */ if (read(in, buffer, 8) <= 0) { printf("Socket read error: %d\n", errno); exit (-1); } for (;;) { FD_ZERO(&inmask); FD_SET(in, &inmask); timeout.tv_sec = TIME_INCR; timeout.tv_usec = 0; maxfd = NOFILE + 1; nfound = select(maxfd, &inmask, (fd_set *)0, (fd_set *)0, &timeout ); if (nfound < 0) { printf ("error\n"); exit(errno); } crashdate -= TIME_INCR; printf ("Time before crash in seconds: %d\r", crashdate); fflush(stdout); if (FD_ISSET(in, &inmask)) { int nbytes; printf("\nReceived someting on the socket\n"); if (ioctl(in, FIONREAD, &nbytes) < 0) { printf ("error\n"); exit(errno); } if (nbytes == 0) { printf("0 bytes received, it should be an error ...\n"); } if (read(in, buffer, 8) <= 0) { printf("Socket read error: %d (should be 60 ETIMEOUT)\n", errno); exit (-1); } } } } /************************* END RCVER ****************************/ ----- End Included Message -----