UDP 套接字无法接收 ECONNREFUSED [英] UDP socket fail to receive ECONNREFUSED

查看:169
本文介绍了UDP 套接字无法接收 ECONNREFUSED的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用:socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP) 创建了一个套接字.

I created a socket using: socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP).

根据this,如果我多次发送简单数据包(乘以 send() 和/或 sendto()),我可以得到 ECONNREFUSED.ICMP 应该告诉之前的数据包没有到达并且 ECONNREFUSED 应该出现.但它失败了,errno 不报告任何错误,并且 send() 总是返回发送的字节数.

According to this, if I send simple packet several times (multiply send() and/or sendto()), I can get ECONNREFUSED. ICMP should tell that previous packet didn't arrive and ECONNREFUSED should appear. But it fails, errno doesn't report about any errors, and send() always returns number of bytes sent.

UDP 协议实际上不应该告诉数据包已发送.但据我了解,ICMP 可以提供建议.

UDP protocol actually shouldn't tell that packet was sent. But ICMP can give advice as I understand.

那么,问题是 - 为什么它无法收到 ECONNREFUSED?

So, the question is - why does it fail to receive ECONNREFUSED?

一切都是使用 Winsock 完成的.

Everything is done using Winsock.

推荐答案

这可能有两个原因.

  • 目标机器没有(出于某种原因)发送回 ICMP
  • 目标机器确实ICMP 发送回,但 winsock 没有正确解释它(我知道某些较旧的 Unix 做到了这一点)
  • The target machine does not (for some reason) send the ICMP back
  • The target machines does send the ICMP back but winsock doesn't correctly interpret it (I know that certain older Unixes did this)

简而言之,最好的办法是使用嗅探器.尝试使用wireshark,看看是否能恢复ICMP.

In short, your best bet to find out would be using a sniffer. Try wireshark and see if you get an ICMP back.

这篇关于UDP 套接字无法接收 ECONNREFUSED的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆