TCP and UDP Socket Server on a WAN

后端 未结 1 1731
感动是毒
感动是毒 2021-02-06 17:40

I am attempting to create a server and client that utilizes both TCP and UDP. The server works very well in a LAN setting but the UDP messages are not being received when trans

相关标签:
1条回答
  • 2021-02-06 18:06

    If you're not getting any traffic it is probably simply blocked by the firewall. In this case it is not about forwarding, it is about opening the port.

    Most (if not all) NAT/Firewall devices will allow UDP traffic in both directions once a hole is punched through the NAT. That is, if my laptop here, sitting behind a NAT/firewall, sends a UDP packet out to the Internet my NAT/firewall will allow return UDP traffic to the originating port number through. I work a lot with UDP and my experience is that this is the rule and very few exceptions.

    Keep in mind though UDP packets are not guaranteed to be delivered.

    Is your client behind a NAT? Do any packets the client send get to the server? Is the problem in the server to client direction?

    If you use the same port number for UDP and TCP this will not change the situation. You can't piggyback on a TCP connection because it is a different protocol.

    Network Address Translation (NAT) Behavioral Requirements for Unicast UDP

    http://en.wikipedia.org/wiki/UDP_hole_punching

    0 讨论(0)
提交回复
热议问题