reading on sockets when connection breaks
Michael@CUNYVM.CUNY.EDU N. Lipp
mnl%IDTSUN1.E-TECHNIK.TH-DARMSTADT.DE at BRL.MIL
Thu Dec 6 15:18:10 AEST 1990
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 at DDATHD21.BITNET
! Merckstr. 25 ! (local: mnl at idtsun1)
! D-6100 Darmstadt (Germany) `------------------------------
! Phone: 49-6151-163776 Fax: 49-6151-164976
-----------------'------------------------------'------------------------------
More information about the Comp.unix.questions
mailing list