Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!udel!haven!adm!news From: mnl%IDTSUN1.E-TECHNIK.TH-DARMSTADT.DE@BRL.MIL (Michael@CUNYVM.CUNY.EDU N. Lipp) Newsgroups: comp.unix.questions Subject: reading on sockets when connection breaks Message-ID: <25205@adm.brl.mil> Date: 6 Dec 90 04:18:10 GMT Sender: news@adm.brl.mil Lines: 25 Hello, I have a program that establishes a TCP-connection with another machine, requests the server to send some packets of data and then does a while (read (fd, &packet, sizeof (packet)) == sizeof (packet)) { ... } This program hangs frequently. I made it QUIT and found it hanging in the read. As this program frequently connects to diskless machines that are switched off at night, I assume that the connection comes down while the program is reading. I am wondering: shouldn't read return with an error status if the connection breaks? As it apparently does not, what is the most reasonable fix? A blocking read with timeout comes to my mind, but what is the best way to do this? Thanks Michael -----------------,------------------------------,------------------------------ Michael N. Lipp ! Institut fuer Datentechnik ! XDATMNLX@DDATHD21.BITNET ! Merckstr. 25 ! (local: mnl@idtsun1) ! D-6100 Darmstadt (Germany) `------------------------------ ! Phone: 49-6151-163776 Fax: 49-6151-164976 -----------------'------------------------------'------------------------------