Windows CE上套接字连接的调整超时时间 [英] Tweak timeout period for socket connections on Windows CE
问题描述
我正在测试我们的软件如何处理连接失败.我们将 socket.BeginConnect
与回调函数集一起使用.端点IP地址和/或端口号是故意无效的.每次在〜21s之后都会调用回调函数(当然有超时和连接失败).我希望可以调整超时时间以进行测试或最终部署.
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.
根据此Windows CE 5.0的MSDN文章,键 HKLM \ Comm \ Tcpip \ Parms \ TcpInitialRTT
看起来很有帮助.但是我尝试了值1、2、3和22,并且超时从〜21s不变.每次更改后,计算机都会重新启动.
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.
可以在操作系统级别调整TCP/IP套接字连接的超时吗?使用C#和.NET Compact Framework.
Can the timeout for TCP/IP socket connections be tweaked at OS level? Using C# and .NET Compact Framework.
推荐答案
您必须使用
IAsyncResult result = mysocket.BeginConnect(...)
然后等待
result.AsyncWaitHandle.WaitOne(yourtimeouthere, false);
这篇关于Windows CE上套接字连接的调整超时时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!