How to detect a closed TCP/IP connection

william <williano-y7mWNqJcIDpfJ/[email protected]>
Newsgroups gmane.comp.hardware.microcontrollers.tini
Message-ID <[email protected]>
Hi,

I'm trying to build a tcp server using keil C and DS80c400, but I'm 
found an weird problem: How to detect a closed connection? I've tried to 
stay in an "while" loop, calling the "avail" function at each iteration, 
but the "avail" returns "0" even when the conection is closed by the 
other side. The documentation says that "avail"  and "recv" should 
return -1 (0xffff) if there is an error, 0 if there is no data, or the 
number of bytes actually ready to be read. I'm think that a closed 
connection is an error condition, isn't?

ps: I'm able to receive "normal"  data, in this case "avail" returns the 
correct number of bytes received.
pps: I just tested using a win2k client, but I hope that the OS is not 
the problem.

Any idea?

William.

_______________________________________________
TINI mailing list
TINI-6tN4nzCoH/[email protected]
To UNSUBSCRIBE, edit your profile, or see list archives:
http://lists.dalsemi.com/mailman/listinfo/tini
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.