0

So I made a simple game where two players can connect to play together - one of them chooses the server option(and then the game starts listening for incoming TCP syncs), and the other enters the IP of the server player to establish the connection and exchange gameplay data over the TCP socket.

Usual stuff.

But the players can connect only if their computers are in the same LAN and the client enters the server's private IP address.

So I guess that if the players are in different LANs, the server must have port forward the game port(55555), and then any client can connect by entering the public IP address.

Is it true(currently I don't have the means to test it), and what are the common ways to avoid port forwarding, because most users don't know how to do it.

Or it's impossible for two applications to connect over WAN without one of the sides setting up port forwarding?

1
  • PortForward has detailed instructions for almost every router model.
    – DavidPostill
    Commented Oct 14, 2014 at 10:17

1 Answer 1

0

You will need to perform port forwarding for the Server that is hosting the 'session'.

The only way round this really is to have a dedicated Server that is always listening for users so that users who try to play the game do not host their own session but instead use a Server dedicated for the game...

However it is normally quite simply to port forward most router guides contain instructions on completing this. The problem you will have is that public IP's for home users are rarely static and will change causing the 'known' public IP to be wrong..

5
  • So the steps before each game connection will be: 1. Server checks and announces his current WAN IP. 2. Server port forwards the game port(if it hasn't done it before). 3. Client enters the server WAN IP and they establish the connection. Anyway the game is just a test project and since nearly every residential users are behind routers it's inevitable, but it's easily done if one of the players knows these steps.
    – Netasd
    Commented Oct 14, 2014 at 10:27
  • Sounds logically except your correct it will not be able to port forward on the router only on its local firewall (if running one). Like you say for a project its fine for further expansion you would need to host a server for your players :)
    – CharlesH
    Commented Oct 14, 2014 at 10:29
  • The user would have to port forward on the router to the internal IP of the server (again making sure this is static and not DHCP or it will change and break the port forwarding)
    – CharlesH
    Commented Oct 14, 2014 at 10:29
  • Yes or the DHCP Address Reservation option.
    – Netasd
    Commented Oct 14, 2014 at 10:31
  • Yep that'll do :)
    – CharlesH
    Commented Oct 14, 2014 at 10:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .