Search code examples
network-programmingudplan

How to send UDP packets to clients who are on the same LAN


I'm currently working on the UDP networking of a game.

Let's say there are two players on the same NAT/LAN. They consequently share the same external IP. They both join the same game server which is at another location and has a different external IP.

How can the game server send UDP packets to a specific player over the LAN?

Everything is fine when every player is on a different LAN, but when two or more are on the same LAN I know don't how to reach them.

BTW I'm using C# but I guess it doesn't really matters here.


Solution

  • By your description I assume their access to the server is through a NATting device. In this case you don't have anything to do, the two clients will be seen coming from the same IP address but different source port, hence easily distinguishable.