Online Multiplayer cant connect from a different pc in the same network

Hello,
I am neither a newbie nor a professional with game maker. Yesterday, I just picked it up again and wanted to learn something about networking. I am still using Game Maker 1.4 but this shouldnt be a big probled, or is it?
I was following a tutorial on youtube from Heart Beast about online multiplayer and it all works fine on my pc with server and client, but as the title states on a different pc in my network the connection fails.

Server Project:

obj_server:

Create event:
GML:
/// Initialize the server object
var type = network_socket_tcp;
var port = 8000;
max_clients = 1;
server = network_create_server(type, port, max_clients)
socket = noone;
buffer = buffer_create(9, buffer_grow, 1);
Networking Event:
GML:
/// Check for clients and data
var type_event = async_load[? "type"];
switch(type_event) {
    case network_type_connect:
        // Add the client to the socket variable
        if (socket == noone) {
            socket = async_load[? "socket"];
            show_debug_message(socket);
        }
        
        break;
        
    case network_type_disconnect:
        // Remove the client from the socket variable
        socket = noone;
        show_debug_message(socket)
        break;
        
    case network_type_data:
        // Handle the data
        var buffer = async_load[? "buffer"];
        buffer_seek(buffer, buffer_seek_start, 0);
        scr_received_packet(buffer);
        break;
}


Client Project:

obj_client:

Create event:
GML:
/// initialize the client
var type = network_socket_tcp;
var ip = global.server_ip;
var port = 8000;
socket = network_create_socket(type);
network_set_config(network_config_connect_timeout, 4000);
network_set_config(network_config_use_non_blocking_socket, 1);
connection = network_connect(socket, ip, port);

var size = 1024;
var type = buffer_fixed;
var alignment = 1;
buffer = buffer_create(size, type, alignment);
Networking Event:
GML:
/// Check for server and data
var type_event = async_load[? "type"];

switch(type_event)
{
    case network_type_non_blocking_connect:
        // check if connection is possible
        var succeeded = ds_map_find_value(async_load, "succeeded");
        
        if succeeded == 0 {
            show_message("Could not find server!");
            game_restart();
        }else {
            // send a buffer to request all dot data
            var buffer_req = buffer_create(1, buffer_fixed, 1);
            buffer_seek(buffer_req, buffer_seek_start, 0);
            buffer_write(buffer_req, buffer_u8, 3);
            network_send_packet(socket, buffer_req, buffer_tell(buffer_req));
            
            room_goto_next();
        }
        break;
    
    case network_type_data:
        // Handle the data
        var buffer = async_load[? "buffer"]
        buffer_seek(buffer, buffer_seek_start, 0);
        scr_received_packet(buffer);
        break;       
}
Download Links for the projects:
Client: https://www.dropbox.com/sh/0pakhhmf92onslx/AACwUcW_eufcEA3ciFBQZ3G5a?dl=1
Server: https://www.dropbox.com/sh/91oi7kziorlct99/AADidO7KaeRvMu8SEVtiwp4_a?dl=1

I hope someone can help me.
Best regards
Potatütata / Potatuetata
 

O.Stogden

Member
As it's on the same network, it's probably not port related.

The client is getting the server ip from the variable "global.server_ip" in its create event.

Make sure that global.server_ip is the local IP of the PC you're connecting to, and it's not set to 127.0.0.1 or "localhost".
 
As it's on the same network, it's probably not port related.

The client is getting the server ip from the variable "global.server_ip" in its create event.

Make sure that global.server_ip is the local IP of the PC you're connecting to, and it's not set to 127.0.0.1 or "localhost".
The ip is set to 192.168.178.34 which is my local ip :/
 

O.Stogden

Member
And just to confirm that these 2 PC's are connected to the same router? If not, then what Shut said is most likely the problem, the ports aren't forwarded.

Otherwise I'm not sure what the difference there would be between the 2 scenarios. Unless one of your local PC's has some sort of hyper-alert antivirus/protection that's stopping the connection, but usually they don't bother with LAN connections.
 
And just to confirm that these 2 PC's are connected to the same router? If not, then what Shut said is most likely the problem, the ports aren't forwarded.

Otherwise I'm not sure what the difference there would be between the 2 scenarios. Unless one of your local PC's has some sort of hyper-alert antivirus/protection that's stopping the connection, but usually they don't bother with LAN connections.
They are both connected to the same router and i can even ping both of them from the other pc with the cmd command. I have tried with and without port forwarding but both dont seem to work. I am as confused as you are :/
 

O.Stogden

Member
Does it display the "could not find server" message that it's set to display if no connection is made?

Also increasing max_clients from 1 probably isn't a bad idea, just in case there's a connection that's being left on there for some reason. I'm not overly familiar with Heartbeast's network tutorial.
 
Does it display the "could not find server" message that it's set to display if no connection is made?

Also increasing max_clients from 1 probably isn't a bad idea, just in case there's a connection that's being left on there for some reason. I'm not overly familiar with Heartbeast's network tutorial.
Thanks for the help mate. It works now but i dont know what i did. I only changed the port from 8000 to 36000 and now it seems to work. the max_clients didnt change anything and i also didnt forward the port.
 

O.Stogden

Member
A lot of things use Port 8000, maybe something didn't like it on the computer, usually best to use a port number that isn't popularly used. Glad it's working now anyway.
 
Top