enet-p2p
enet-p2p copied to clipboard
Connecting fails with computers on LAN and external serve
Running the server on external ip (with port forwarded obviously) works fine with computers on different IP addresses. (networks)
Example: Server IP1 (Port forwarded) Client IP2 (Behind NAT) Client IP3 (Behind NAT) = WORKS
Not working example: Server IP1 (Port forwarded) Client IP2 (Behind same NAT) Client IP2 (Behind same NAT) = DOES NOT WORK
It fails to connect to the other peer on line: ENetPeer* peerRemote = enet_host_connect(host, &addr, 2, 0);
peerRemote->state is stuck at ENET_PEER_STATE_CONNECTING forever.
There's a chance the router can see that a client from its network is trying to connect to itself and then not route it as expected. Perhaps a good solution would be to detect the case of being behind the same NAT and public IP address, and then route it through local IP addresses instead.
What if there is 3 players on LAN 1 and 2 players on LAN 2?
I guess that depends on your actual implementation of your game lobbies. You could pick one of those players as the host, then connections could be made in a directed manner.