0

I'm trying to develop a small multiplayer game and I've been reading a lot about how NAT makes P2P impossible. On the other hand I've read a lot of server code which looks something like:

https://docs.python.org/3/library/asyncio-protocol.html#udp-echo-server

def datagram_received(self, data, addr):
    message = data.decode()
    print('Received %r from %s' % (message, addr))
    print('Send %r to %s' % (message, addr))
    self.transport.sendto(data, addr)

In the above code the server talks to the client using only plain IP address. Similarly this stackoverflow question

So what am I missing here - is there another way to write UDP send calls or does having them sit on a server auto-magically solves NAT?

stuartd
  • 70,509
  • 14
  • 132
  • 163

1 Answers1

0

The crucial part is this one: client.Connect(ep);. The client is the one opening the connection to the server. If a connection is established, the client's router knows where to route incoming packets over the public port.

Having just a server does not circumvent the NAT problem. The same issues as with P2P would exists.

Maurice
  • 346
  • 2
  • 6