• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM Different Computers Won't Connect...

E

EndermanTamer13

Guest
I'm trying to make a online multiplayer game where separate computers can connect to play the game, but the client won't connect to the server! It works when I run the server and the client from the same computer, but not from different computers. If it doesn't work from different computers, that defeats the whole purpose!

Can anyone help me get this problem figured out?
 

Binsk

Member
Networking is complicated. There are a vast amount of things that can go wrong and if any of them do you won't be able to connect. If you didn't catch the hint, this means it is near impossible to help you with absolutely zero information about your project.

Now, because you strike me as rather new to networking I will assume you are making a mistake common to those learning the concepts and hopefully get lucky in my guess.

If you are connecting with the IP address 127.0.0.1, it is a localhost IP address and will not work between computers because it is not the computer's real IP address.

If you are using an IP address starting with 192 or 10 then it is your internal IP address (there are other internal IP addresses as well, but the most common ones start with one of those numbers). This means that only computers in your actual household will be able to connect.

If none of those numbers look familiar to you then it just may be possible you are actually using your external IP address, aka. the IP address you get when going to whatismyip.org, aka. the IP address of your actual router, aka. the IP address accessible to the entire world. However, in this case, as it is your router's IP address, connecting to it won't connect to your computer unless you forward all the ports that your game uses to point to your computer's internal IP address so that when someone attempts to connect to your external address your router will pass all the info to your computer and thus your game.

To actually forward your ports requires you to go into your router's settings and has nothing to do with your game itself.

Now, all this said, would you mind telling us a few basic things?
  • What is your host (aka. the computer running the 'server') IP address?
  • If it is different, what is the IP you are trying to connect to?
  • When other computers try to connect are they inside your house or outside your house?
  • If outside the house, have you forwarded the correct ports on your router?
 
E

EndermanTamer13

Guest
  • What is your host (aka. the computer running the 'server') IP address?
  • If it is different, what is the IP you are trying to connect to?
  • When other computers try to connect are they inside your house or outside your house?
  • If outside the house, have you forwarded the correct ports on your router?
1. 192.168.10.11
2. My router's IP. I'm not home right now, so I can't tell you what it is right away.
3. Inside. I've never tried outside. I was gonna get connections inside the house working before I moved onto outside connections.
4. So far my game only uses port 36000 and I have that forwarded to 192.168.10.11, AKA my computer.

I have all my code correct, it just seems to fail...
 

Binsk

Member
Alright, because you said your host IP is 192.168.10.11, that is the IP you should connect to when in the house. You don't need to try to go 'through the router' specifically because it already knows your devices and will rout the connection just fine.

On a similar note, you don't need port forwarding when inside your home. The port forwarding only affects those connecting from the outside world.

When you finally DO move on to connecting from outside make sure that your ports are forwarded to your internal IP address for the computer (as it seems you have done) and have the client connect to the EXTERNAL IP address of the router. Again, go to whatismyip.org to find that address. If the first three numbers are 192 then it is your internal (and thus incorrect) address.

Basically this is how it works:
  • Your entire house has a single IP address that represents all your devices to the world.
  • Your router assigns local IPs that only it and your devices know that fall under this giant umbrella IP.
  • When data comes to the umbrella IP it goes to the router under a specific port and the router then passes it on to one of the local devices.
  • Port forwarding simply defines which device the data should go to.
Now as you may see, when you are in the house you are already past the 'umbrella' so you don't need the port forwarding, just the IP of the device.

Anyways, I hope that helps.

Edit: One small thing I think I should mention. Not all routers allow connecting to the external address from inside the umbrella. Mine, for example, doesn't allow this and I am required to use internal addresses when inside and external when outside even though it should rout to my server regardless. Just something to keep in mind.
 
Last edited:
E

EndermanTamer13

Guest
Alright, because you said your host IP is 192.168.10.11, that is the IP you should connect to when in the house. You don't need to try to go 'through the router' specifically because it already knows your devices and will rout the connection just fine.
I have the code set to ask you the IP you want to connect to. You put it in and it is supposed to connect. I put in 192.168.10.11 and it goes to a white screen. Nothing happens. Is there something else I'm doing wrong? If I have to post my code I can.
 

Binsk

Member
1) How do you know it is not connecting? What is supposed to happen when you connect?
2) Giving us your hosting and connecting code might be beneficial.
3) You said it was working when running on the one machine, what were you doing there to connect?

I don't know what is supposed to happen in your game when you connect. Why don't you try putting some debugging messages that tell you if a connection was made or if it failed just to make sure?
 
E

EndermanTamer13

Guest
1) How do you know it is not connecting? What is supposed to happen when you connect?
2) Giving us your hosting and connecting code might be beneficial.
3) You said it was working when running on the one machine, what were you doing there to connect?

I don't know what is supposed to happen in your game when you connect. Why don't you try putting some debugging messages that tell you if a connection was made or if it failed just to make sure?

1. Right now I have a test game that I'm doing to get things figured out before I make the real game. When the client connects, it is supposed to send data about a platforming level to the server. So each wall will send its location to the server, and then the server will create it in the appropriate location. You can also click anywhere in the client, and it will send where the click was to the server. But if I'm using separate computers, when I put in the IP to connect, I have a white screen. Nothing. The server doesn't even say a client connected.

3. I know I'm doing this out of order, but I want to include the answer to question 2 last. I have the code exactly the same as it was when it worked on the same machine, so I don't know what the problem is.

2. Here is the server start code:
Code:
/// Initialize the server object
var type = network_socket_tcp;
var port = 36000;
max_clients = 1;
server = network_create_server(type,port,max_clients);
socket = noone;

The script for when the server recieves a packet:
Code:
///scr_received_packet(buffer)
var buffer = argument0;
var message_id = buffer_read(buffer,buffer_u8);

switch (message_id){
    case 1:
        var mx = buffer_read(buffer,buffer_u32);
        var my = buffer_read(buffer,buffer_u32);
        instance_create(mx,my,obj_click);
        break;
    case 2:
        var object = buffer_read(buffer,buffer_u32);
        var ox = buffer_read(buffer,buffer_u32);
        var oy = buffer_read(buffer,buffer_u32);
        instance_create(ox,oy,object);
        break;
    case 3:
        var object = buffer_read(buffer,buffer_u32);
        var ox = buffer_read(buffer,buffer_u32);
        var oy = buffer_read(buffer,buffer_u32);
        object.x = ox;
        object.y = oy;
        break;
      
}

Client object create/client join code:
Code:
/// Initialize the client
var type = network_socket_tcp;
var ip = get_string("What IP address would you like to join?","");
var port = 36000;
global.socket = network_create_socket(type);
connection = network_connect(global.socket,ip,port);

var size = 1024;
var type = buffer_fixed;
var alignment = 1;
global.buffer = buffer_create(size,type,alignment);

Client object disconnect/End Game code:
Code:
/// Destroy the socket and the buffer
network_destroy(global.socket);
buffer_delete(global.buffer);
If you need the code for sending packets I can include that, but you didn't say you needed it, so I won't post it right away.

I've also tested connecting from the same computer and it works fine. Don't know what the problem is...
 
N

NosiriN

Guest
please is there a fix for this im also having the same problem its really fustrating
 

The-any-Key

Member
This is a broad issue.
When you try to make an online connection between two different computers on two different networks. You will have to fight against a bunch of enemies.
To connect to an outside computer you will need to send some kind of connection request to the computer you want to connect to.
  1. So you need the public/external IP of the server computer. Most of the time you can get that using: https://www.whatismyip.com/
  2. Note that this wont show the correct IP if you are behind a proxy or firewall that change IP or some symmetric NATs (So it wont work in schools or in workplaces or if you use 3G/4G internet)
  3. When you get the correct external IP (And there is really no good way to know if you do) you need to make sure there is no antivirus or firewalls that stop the message on your computer.
  4. Now the message is in your router and you must make sure that the routers security don't block any outgoing messages (some routers have "gaming disabled").
  5. Now when the message is on it's way it may be blocked by your internet provider NAT, some stop this because they only allow simple surfing, so no cheap providers.
  6. When the message is travelling to your receiver his internet provider NAT may block the message, so make sure your receiver don't have any cheap internet provider.
  7. The message is now in the receivers router. Now you need to port forward. So all messages on the receiver port is pointing to the local IP to the computer where the server is and on the port the server listen on.
  8. The message is now on its way to the server computer and you now need to make sure he don't have any antivirus or firewall that block the message.
  9. Finally the message is received by the server and can send a response.
  10. The server computer antivirus and firewall must allow to send a message back.
  11. The message come to the router and the router must allow to send a response (some routers have "gaming disabled").
  12. After that the tuple line should allow a safe path back to the sender.
  13. And you are now connected.
When you fixed all these things. You can connect to another computer.
 

moonbug12

Member
i need help with this too, can someone help me with the code to change the ip from the external to the internal? how is this done in game?
 
Top