Socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, timeout);如果超时设置为-1,则该方法在Windows上运行良好,但在Linux和Mac上失败,例外情况如下
System.Net.Sockets.Socket.UpdateStatusAfterSocketErrorAndThrowException(SocketError错误处的无效参数,System.Net.Sockets.Socket.SetSocketOption(SocketOptionLevel optionLevel处的字符串callerName,SocketOptionName optionName,Int32 optionValue,布尔静默( System.Net.Sockets.Socket.SetSocketOption(SocketOptionLevel optionLevel,SocketOptionName optionName,Int32 optionValue)
如果在mac和linux上将超时设置为0,则没有例外。
1)如果超时设置为-1,则在windows上进行无限期轮询。timeout=0会在windows上做同样的事情吗?
2)在linux上,如果超时设置为0?它做无限期的民意调查吗?
当我使用0作为超时时,应用程序会间歇性地失败。
System.NotSupportedException: The BeginWrite method cannot be called >when another write operation is pending. at System.Net.Security.\_SslStream.ProcessWrite(Byte[] buffer, >Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest) at System.Net.Security.\_SslStream.BeginWrite(Byte[] buffer, Int32 >offset, Int32 count, AsyncCallback asyncCallback, Object asyncState)
发布于 2019-06-14 10:13:45
1)如果超时设置为-1,则在windows上进行无限期轮询。timeout=0会在windows上做同样的事情吗? 2)在linux上,如果超时设置为0?它做无限期的民意调查吗?
是的,根据Socket.RecieveTimeout的文档,0和-1的值都具有相同的行为。
超时值,以毫秒为单位。默认值为0,表示无限超时期.指定-1还表示无限超时期.
https://stackoverflow.com/questions/56595926
复制相似问题