C# udpclient.send 到假IP太慢而无法完成
当我 udpclient.send 到一个假/未知 ip 时,该过程需要很长时间才能完成(每次调用大约 2 秒。对于 1000 个调用,大约需要 2000 秒)。如果我 udpclient.send 到一个已知的 ip,发送 1000 个数据包花费的时间不到 2 秒。
我正在使用发送进行开发,这种事情使得开发过程花费了很长时间。有没有办法防止这种减速?仅供参考,我确实输入了 IP 地址(不是主机名以防止 dns 解析),我确实尝试使用 udpclient.connect 但问题仍然存在。
谢谢。
when i udpclient.send to an fake/unknown ip, the process took a long time to complete(about 2 seconds per call. for 1000 calls it took about 2000 seconds). if i udpclient.send to a known ip, sending 1000 packets took less than 2 seconds.
i was using send for development and this kind of things makes development process took a long time. is there a way to prevent this slowdown? fyi, i did put ip address(not hostname to prevent dns resolve), i did try use udpclient.connect but the problem still persist.
thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如您现在已经猜到的,这是 DNS 问题。
在本地计算机中,您可以在
/etc/hosts
中编写(假设您正在 Linux 上进行开发),如下所示的条目:那么名称“target-develop”的解析将只需要一点时间。
编辑
如果您将数据包发送到未知/假IP并且花费很长时间,则可能是防火墙的配置问题。
As you have guessed by now, this is DNS problem.
In your local machine, you could write in
/etc/hosts
(assuming you are developing on Linux), an entry like:then the resolution of name "target-develop" will take only a moment.
EDIT
If you send packets to unknown/fake IP and it takes long time, it could be a firewall's configuration problem.