正在send如何判断客户端己断开

来源:百度知道 编辑:UC知道 时间:2024/05/18 01:22:58
在普通的阻塞套接字上。因为会send大量数据,所以判断客户端己断开很重要。求个判断客户端己断开的解决方案。
我用select去判断套接字是否可写,好像不管用。

send函数
返回值为0表示断开
返回值-1为错误

刷新

应该会收到异常的吧

[C#]
// This derived class demonstrates the use of three protected methods belonging to the TcpClient class
public class MyTcpClientDerivedClass : TcpClient
{

// Constructor for the derived class.
public MyTcpClientDerivedClass() : base()
{
}
public void UsingProtectedMethods()
{

// Uses the protected 'Active' property belonging to the TcpClient base class
// to determine if a connection is established.
if (this.Active){
// Calls the protected 'Client' property belonging to the TcpClient base class.
Socket s = this.Client;
// Uses the Socket returned