日期:2014-05-18 浏览次数:20781 次
try { int receivedBytesCount = socket.Receive(DataBuffer, DataBufferSize - DataBufferSizeLast, SocketFlags.None); if (receivedBytesCount == 0) { //socket连接已断开,可以重连,可以断开 return; } //数据处理 } catch (SocketException e) { //10035 == WSAEWOULDBLOCK if (e.NativeErrorCode.Equals(10035)) { //仍然处于连接状态,但是发送可能被阻塞 } else { //连接错误,返回错误代码:e.NativeErrorCode return; } } catch(Exception e) { //其他异常 }