Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当我将 udpclient.send 发送到假/未知 ip 时,该过程需要很长时间才能完成(每次通话大约 2 秒。对于 1000 次通话,大约需要 2000 秒)。如果我 udpclient.send 到一个已知的 IP,发送 1000 个数据包不到 2 秒。
我正在使用发送进行开发,这种事情使开发过程花费了很长时间。有没有办法防止这种放缓?仅供参考,我确实输入了 IP 地址(不是主机名以防止 dns 解析),我确实尝试使用 udpclient.connect 但问题仍然存在。
谢谢。
正如您现在已经猜到的那样,这是 DNS 问题。
在您的本地机器上,您可以写入/etc/hosts(假设您在 Linux 上开发),这样的条目:
/etc/hosts
192.168.1.20 target-develop
那么名称“target-develop”的解析将只需要片刻。
编辑
如果您将数据包发送到未知/假 IP 并且需要很长时间,则可能是防火墙的配置问题。