请教高手:SocketAsyncEventArgs 类服务端如何设置心跳超时

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了请教高手:SocketAsyncEventArgs 类服务端如何设置心跳超时相关的知识,希望对你有一定的参考价值。

private void ProcessAccept(SocketAsyncEventArgs e)

Interlocked.Increment(ref m_numConnectedSockets);
Console.WriteLine("Client connection accepted. There are 0 clients connected to the server",
m_numConnectedSockets);

e.AcceptSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, 3000);

// Get the socket for the accepted client connection and put it into the
//ReadEventArg object user token
SocketAsyncEventArgs readEventArgs = m_readWritePool.Pop();
((AsyncUserToken)readEventArgs.UserToken).Socket = e.AcceptSocket;
// As soon as the client is connected, post a receive to the connection
bool willRaiseEvent = e.AcceptSocket.ReceiveAsync(readEventArgs);
if (!willRaiseEvent)

ProcessReceive(readEventArgs);


// Accept the next connection request
StartAccept(e);

通过: e.AcceptSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, 3000); 设置3秒无效。

参考技术A 这问题我也遇到了,同求

以上是关于请教高手:SocketAsyncEventArgs 类服务端如何设置心跳超时的主要内容,如果未能解决你的问题,请参考以下文章

请教高手

请教CAD高手

像matlab高手请教

请教ACCESS高手一个问题!在线等,急呀!

MSSQL 高手请进,有问题请教!!

请教ROS GHOST 安装不了 高手指教!!!!!!!!!!!如题 谢谢了