GML [Solved] Client from a different machine won't connect to the server locally?

XirmiX

Member
Not long ago, I tried out having a wifi connection with two computers connecting to the same wifi, and since what I have here is said to be local connection, I thought this should work between two machines of the same connection. May be I'm misunderstanding something, but for whatever reason, when launching the server from one computer and then launching the client from the other, the machine with the client cannot connect to the server? Anyone have any ideas why? Here's the initial connection code I have that may be relevant here. Having a client launch on the machine that had the server running did have the client connect, however, so I know the connection works overall. It simply doesn't work between two machines, even if they're in the same room and I'm not sure why.

Server object creation code
Code:
randomize();
//declaring the type of connection (tcp)
server_type = network_socket_tcp;
//port number
port = 50000;
//max amount of clients that can connect to the server
max_players = 6;
//generating a server
server = network_create_server(server_type, port, max_players);
Client object creation code
Code:
{
var port = 50001;
IP = "127.0.0.1";
socket_plug = network_create_socket_ext(network_socket_tcp, port);
while (socket_plug < 0 && port < 65535)
{
    port++
    socket_plug = network_create_socket_ext(network_socket_tcp, port);
}

network_connect(socket_plug, IP, 50000);
If this is only meant for the same machine (which, would actually be pretty stupid, I mean a server connection all for the same machine? Can do that without it!) then how could I do it so that, at least locally, you can connect to another machine nearby through the router or something. I have heard of using the router as a server, and perhaps there-in lies the problem, but I have no idea how to do that. I mean, how am I going to launch a GML executable from something that doesn't have things like RAM (idk, may be it does, not a specialist in router technology)?
 

FrostyCat

Member
The 127.0.0.1 address in the client code means yourself. If you want to connect to another machine in your LAN, replace that with the LAN IP address of that other machine or a call to get_string to receive an IP address from the user.
 

XirmiX

Member
The 127.0.0.1 address in the client code means yourself. If you want to connect to another machine in your LAN, replace that with the LAN IP address of that other machine or a call to get_string to receive an IP address from the user.
So, the address that I can search up on google by googling "my IP address"? Well, lets say the client has that, now I can't even connect to the server on the same machine anymore; the client crashes (not responding). But when I do the 127.0.0.1 it works, so I know stuff hasn't been breaking due to me adding content along the way.
 
If they're on the same router network as you, you'll need your internal ip address.

one way you can get that is by doing command prompt, type ipconfig and press enter. You'll see a IPv4 Address, and your clients on your local network should be able to connect that way. Make sure firewalls allow traffic.

there's a way of getting the lan ip automatically by having the server send out a udp broadcast, the clients can recieve that message and get the ip address out of it with: ip = async_load[? "ip" ]; They can then use that to connect to the server.
 

XirmiX

Member
@flyingsaucerinvasion I get this error with the internal IP:
upload_2017-9-4_14-18-45.png

EDIT: Never mind, I entered an integer instead of a string, it works fine now. Thanks! I'll look into global play later on in development!
 
Last edited:
Top