C# - WireShark 检测传入数据包,但应用程序未收到它们
我有一个奇怪的问题。我有一个客户端向我的服务器发送数据包,但我的服务器 UDP 套接字从未收到它们。如果我发送而他尝试接收,同样的情况也会发生。
检查这个从wireshark捕获的图像: http://img263.imageshack.us/img263/2636/bokus.png
我已将 UDP 套接字绑定到 EndPoint 192.168.2.3(服务器的内部 IP)和端口 9998。 客户端将数据发送到我的 IP,然后将其转发到本地服务器计算机。 正如您所看到的,wireshark 清楚地检测到目标端口 9998 的 192.168.2.3 传入数据包,但没有传递任何内容!
(...为什么它在目标端口中说distinct32?)
I've got a strange problem. I have a client sending packets to my server, but my servers UDP socket never receives them. Same thing happens the other way around, if I send and he tries to receive.
Check this image, captured from wireshark:
http://img263.imageshack.us/img263/2636/bokus.png
I hav bound my UDP socket to EndPoint 192.168.2.3, which is the internal IP of the server, and port 9998.
The client sends data to my IP, which should then be forwarded to the local server machine..
As you can see wireshark clearly detects incomming packets for 192.168.2.3 with destination port 9998 but nothing gets delivered!
(...why does it say distinct32 btw in destination port?)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
其他需要注意的事情是确保您可能运行的任何防火墙都有一个规则设置,以允许您的端口 9998 上的通信。
如果我不得不猜测(需要查看您接收的 C# 代码才能知道),看起来您可能正在尝试接收UDP数据包,但在客户端使用TCP协议。 (或者我可能只是误解了屏幕截图的某些文本。)
使用 UDP 时无需“侦听”连接。 UDP 数据包没有连接/断开协议。它们也不保证数据包的接收顺序与发送顺序相同。
尝试在 C# 客户端中使用类似的内容,看看是否能获取数据。
Something else to watch for is make sure any firewall you might running has a rule setup to allow communications on your port 9998.
If I had to guess (would need to see your recieving C# code to know), It looks like you might be trying to receive UDP packets but using TCP protocol on the client side. (Or i might just be misunderstanding some of the text of your screenshot.)
Theres no need to 'listen' for a connection when using UDP. UDP packets don't have a connect/disconnect protocol. Nor do they guarantee that packets are received in the same order they're sent.
try using something along these lines in your C# client and see if you get data.