On the client side, the socket is blocking, so the recv on the client side is blocking. Therefore, if recv return 0, it means that the other side close the connection. This is where I get the answer: <a href="http://mkssoftware.com/docs/man3/recv.3.asp">
http://mkssoftware.com/docs/man3/recv.3.asp</a>.<br><br><div><span class="gmail_quote">On 10/31/07, <b class="gmail_sendername">Ofer Sadgat</b> &lt;<a href="mailto:ofer@berkeley.edu">ofer@berkeley.edu</a>&gt; wrote:</span>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">








<div link="blue" vlink="purple" lang="EN-US">

<div>

<p>If you have a connection to a server which you send a
request and request a persistent connection but the server refuses. In its
response it includes a Content-Length header. As the client I parse this and receive
content-length data. However, Once I have received the data I continue on with
no more calls to read. However, the server now closes the connection and the
client has no idea of this event. The client then makes a request to the same
server and noticing that that is where it last connected it doesn't establish
a new connection. The following recv call fails.</p>

<p>&nbsp;</p>

<p>How do I fix this? Is there a way to check whether or not a
server has closed the connection without receiving data?</p>

<p>&nbsp;</p>

<p>Thanks,</p>

<p>Ofer</p>

</div>

</div>


<br>_______________________________________________<br>ee122 mailing list<br><a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:ee122@mailman.ICSI.Berkeley.EDU">ee122@mailman.ICSI.Berkeley.EDU</a><br>
<a onclick="return top.js.OpenExtLink(window,event,this)" href="http://mailman.ICSI.Berkeley.EDU/mailman/listinfo/ee122" target="_blank">http://mailman.ICSI.Berkeley.EDU/mailman/listinfo/ee122</a><br><br></blockquote></div>
<br><br clear="all"><br>-- <br>Haley Nguyen