Tweak timeout period for socket connections on Windows CE

孤者浪人 提交于 2019-12-11 04:54:45

问题


I'm testing how our software handles connection failures. We use socket.BeginConnect with a callback function set. The endpoint IP address and/or port number is deliberately invalid. The callback function gets called after ~21s every time (with timeout and connection failure, of course). I'd like to be able to tweak the timeout up or down for testing or final deployment.

According to this MSDN article for Windows CE 5.0, the key HKLM\Comm\Tcpip\Parms\TcpInitialRTT looks helpful. But I've tried the values 1, 2, 3 and 22 and the timeout does not change from ~21s. The computer was rebooted after each change.

Can the timeout for TCP/IP socket connections be tweaked at OS level? Using C# and .NET Compact Framework.


回答1:


You must do so using

IAsyncResult result = mysocket.BeginConnect(...)

then wait on the

result.AsyncWaitHandle.WaitOne(yourtimeouthere, false);


来源:https://stackoverflow.com/questions/44566777/tweak-timeout-period-for-socket-connections-on-windows-ce

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!