问题描述
当我收到连接超时时,我的软件出现了一个错误.这些错误非常罕见(通常是当我的连接被我们的内部网络断开时).我怎样才能人为地产生这种效果,以便我可以测试我们的软件?
I've had a bug in our software that occurs when I receive a connection timeout. These errors are very rare (usually when my connection gets dropped by our internal network). How can I generate this kind of effect artificially so I can test our software?
如果重要,应用程序是使用 CAsyncSocket 类用 C++/MFC 编写的.
If it matters the app is written in C++/MFC using CAsyncSocket classes.
我尝试使用不存在的主机,但出现套接字错误:
I've tried using a non-existent host, and I get the socket error:
WSAEINVAL (10022) 无效参数
我的下一次尝试是使用 Alexander 的建议连接到不同的端口,例如81(虽然在我自己的服务器上).那效果很好.与断开的连接完全相同(等待 60 秒,然后出错).谢谢!
My next attempt was to use Alexander's suggestion of connecting to a different port, e.g. 81 (on my own server though). That worked great. Exactly the same as a dropped connection (60 second wait, then error). Thank you!
推荐答案
连接到现有主机,但连接到防火墙阻止的端口,该端口只会丢弃 TCP SYN 数据包.例如,www.google.com:81.
Connect to an existing host but to a port that is blocked by the firewall that simply drops TCP SYN packets. For example, www.google.com:81.
这篇关于人为造成连接超时错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!