From: Gary Wright Date: 2007-03-22T23:51:28+09:00 Subject: Re: How to Distinguish between a Reset packet and a Normal o On Mar 22, 2007, at 4:52 AM, sairam MP wrote: > I think its possible,while receiving some data,if the length of data > received is zero in a blocked receive function then the connection is > said to be reset by peer. No. A 'reset by peer' is a very specific TCP term. It means that a packet with the RST bit set has arrived on the connection. It is possible to have packets that contain no data (keep alive packets for instance). You can't infer that the connection is dead from that. But the bigger problem is that you can't even see packet arrivals from the application. By the time the data gets to the application the packet boundaries are unknowable. Unless you are talking about kernel programing you are thinking about TCP in a very misleading way. It is a common misunderstanding about TCP that if the sender writes 100 bytes that the receiver will read 100 bytes. That is, that the writes of the sender and the reads of the receiver are always 'paired up'. This is not the way TCP works. Message boundaries are not preserved across a TCP stream nor does each call to 'write' correspond to a single packet on the wire. TCP can coalesce multiple writes into a single packet and can also split a single write into multiple packets. Gary Wright