Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: I created a server/client TCP connection, but it only works locally. Any ideas?  (Read 271 times)

0 Members and 1 Guest are viewing this topic.

meatbeater

  • Newbie
  • *
  • Posts: 1
    • View Profile
So, here's the whole code: https://github.com/Neroooooooo/sfmlNetworking

I posted the github repo link because it's probably more organized. And there are just about 200 lines among 5 files, some of them being comments and cout's, so it shouldn't be hard to understand what's there.

The thing I want to achieve is a server that can receive packets from clients through a TCP connection. Currently, it only works if both the client and the server are on the same machine and I use the local IP to connect. It doesn't even work on 2 different machines connected to the same router.

I tried to forward the port 20000 (used in the code), and connect to the server using the public IP address, but it doesn't work.
https://imgur.com/a/QDhlwAy

I disabled my windows 10 firewalls, it still didn't work.

Can you guys help me here? I'm stuck and I searched everywhere for a solution, but I can't find one. I really want to learn about multiplayer games and networking, but I can't see what I'm doing wrong.


EDIT: I played some more with firewalls, and now it works locally, on 2 different machines connected to the same router. But it does not work with someone that's not connected to the same router. Ideas?
« Last Edit: January 20, 2020, 06:12:14 pm by meatbeater »

Fx8qkaoy

  • Newbie
  • *
  • Posts: 16
    • View Profile
So, here's the whole code: https://github.com/Neroooooooo/sfmlNetworking

I posted the github repo link because it's probably more organized. And there are just about 200 lines among 5 files, some of them being comments and cout's, so it shouldn't be hard to understand what's there.

The thing I want to achieve is a server that can receive packets from clients through a TCP connection. Currently, it only works if both the client and the server are on the same machine and I use the local IP to connect. It doesn't even work on 2 different machines connected to the same router.

I tried to forward the port 20000 (used in the code), and connect to the server using the public IP address, but it doesn't work.
https://imgur.com/a/QDhlwAy

I disabled my windows 10 firewalls, it still didn't work.

Can you guys help me here? I'm stuck and I searched everywhere for a solution, but I can't find one. I really want to learn about multiplayer games and networking, but I can't see what I'm doing wrong.


EDIT: I played some more with firewalls, and now it works locally, on 2 different machines connected to the same router. But it does not work with someone that's not connected to the same router. Ideas?

Haven't took a very deep look, but since it works on same router and not globally the problems may be:
- ur server is not good connected (I listen to local router address and forward it, not connect to public one, deppending on my setup; try both)
- ur client doesn't connect to the public address
- the router is not forwarding the port
- client and server ports doesn't match
U could also try a scenario with a real server probably bought (VPS)

 

anything