用网络流读取数据时,在beginread的回调函数中处理完endread之后,继续调用beginread, 结果在对端关闭连接的时候,程序在endread那一行报错。请问如何知道对方已经关闭连接了呢?private void CallBack(IAsyncResult ar)
{
StateObject so = (StateObject)ar.AsyncState;
int len = so.ns.EndRead(ar); client.BeginRead(so.buffer,0,so.buffer.Length,new AsyncCallback(CallBack),so);
}
{
StateObject so = (StateObject)ar.AsyncState;
int len = so.ns.EndRead(ar); client.BeginRead(so.buffer,0,so.buffer.Length,new AsyncCallback(CallBack),so);
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货