Windows Networking Broadcast for Local Server Browser

cameronac

Member
Whenever I create a Server on my desktop computer it creates a network that's visible to my laptop so I can connect to it. But doing it the other way around my desktop can't seem to see my laptops network. I've disabled all network firewalls. So, I'm not sure what the problem is. I have also used the Gamemaker lan example project and it works the same way. I have the latest version of Gamemaker 2.
 

cameronac

Member
Both Ip's are similar 192.168.0.29, and 192.168.0.34. The Server acts as a tcp and the server browser acts as a udp. Not sure what subnet masks and dhcp is. They are using a wireless connection if that's what your asking.
 

poliver

Member
DHCP is dynamic IP addressing. which means an IP address is assigned automatically to any device connected to the network by the router/modem or some other device that acts as a DHCP server. (This is kinda default how modern public wi-fi and home internet works.)
Alternative is Static IP address. Which guarantees that your IP will never change (this is more common for web servers and business connections which need guaranteed outside access to the network).

Subnet mask 255.255.255.0 means the device can communicate to any other device on the network that shares IP address with same first 3 rows of digits. in your case 192.168.0.XXX.
Which in your case is fine. Both of your devices are on the same subnet.

TCP and UDP are 2 completely different networking protocols. They are not compatible. Make sure you're communicating with your devices using same network protocol.
 
Last edited:

poliver

Member
not enough information

before we assume there's something wrong in the GM code
can you ping your devices both ways? From your desktop to laptop & from laptop to desktop

if your on Windows
  • open either CMD or PowerShell
  • type
    Code:
    ping xxx.xxx.xxx.xxx
  • where xxx is IP address of the other machine your trying to ping
if your on Mac or Linux
  • do the same but in Terminal

Does this time out? or you get a reply?
-------------------------------------------------------------------------------------
What port are you using?
 

poliver

Member
this is weird. wouldn't expect it to time out on both ends since you said your game was working at least one way.

Are you sure both IPs are correct?

Open CMD on both desktop and laptop
Type
Code:
ipconfig
you'll see the IP address under IPv4 Address
then type
Code:
ping xxx.xxx.xxx.xxx
on both machines
on desktop you enter the laptops ip address
on laptop enter desktops ip address

just to make sure there's nothing completely weird going on try to also ping the same machine your on. this shouldn't fail.
 

cameronac

Member
No it still acts the same way. Darn I really thought that would have fixed it. Laptop finds the Desktops signal but not the other way around.
 

poliver

Member
take a look whether there is any firewall setup in your router configuration.
there's usually a default router address printed at the back of the router or any documentation it came with.

try changing the port in the game. it could be that it's used by some other app on either machines.
 

chamaeleon

Member
No it still acts the same way. Darn I really thought that would have fixed it. Laptop finds the Desktops signal but not the other way around.
Maybe it's due to the wifi network being marked as public? Assuming Windows 10 (knowing what OS you're using helpful), right-click wifi icon on taskbar and select open network & internet settings, and check if it says public or private network under network status. If public, click change connection properties and change the network profile to private. Having said all that, maybe it is/became private because you enabled file sharing, etc. Anyway.. Just a thought.
 

poliver

Member
Well considering the fact that you can ping them both now. The communication is there.

It's probably either a busy port or your GM code.
Is it possible for you to upload a stripped down version of your game project that you wouldn't mind to share?

The screens don't tell enough.
 

cameronac

Member
Create:

global.is_server = false;
global.broadcast_server = -1;
global.server = -1;
global.broadcast_buffer = buffer_create(32, buffer_fixed, 1);

ip_address = "127.0.0.1";
port = 2240
clients = ds_list_create();


Step:

if (keyboard_check_pressed(ord("E")) and room == rm_main_menu)
{
room_goto(rm_multiplayer);
}

if (keyboard_check_pressed(ord("D")) and room == rm_main_menu)
{
room_goto(rm_server_browser)
}

Alarm:

buffer_seek(global.broadcast_buffer, buffer_seek_start, 0);
buffer_write(global.broadcast_buffer, buffer_u8, 19);
network_send_broadcast(global.server, port, global.broadcast_buffer, buffer_tell(global.broadcast_buffer));
global.is_server = true;

alarm[1] = room_speed;


Draw:

if (room == rm_main_menu)
{
draw_text(100,100, "Press E for Multiplayer");
}

if (room == rm_main_menu)
{
draw_text(100,200, "Press D for Server Browser");
}

if (room == rm_multiplayer)
{
draw_text(100, 100, "Multiplayer");
}

if (room == rm_server_browser)
{
draw_text(100, 100, "Server Browser");
draw_text(100,200, ip_address)
}


Room Start:

if (room == rm_multiplayer)
{
show_message("Network Created")
if (global.broadcast_server > 0)
{
network_destroy(global.broadcast_server);
}
global.broadcast_server = -1;
global.server = network_create_server(network_socket_udp, port, 4);
global.is_server = true;
alarm[1] = room_speed
}

if (room == rm_server_browser)
{
global.broadcast_server = network_create_server(network_socket_udp, port, 4);
global.is_server = false;
}


Game End:
if (global.broadcast_server > 0)
{
network_destroy(global.broadcast_server)
buffer_delete(global.broadcast_buffer)
}

if (global.is_server == true)
{
network_destroy(global.server)
}


Async - Networking:

//Detecting server broadcast
var eventid = async_load[? "id"]


if (eventid == global.broadcast_server)
{
var ip = async_load[? "ip"]
var buff = async_load[? "buffer"]

var num = buffer_read(buff, buffer_u8);
ip_address = ip;
show_message(ip)
}
 

cameronac

Member
That's all in one object. You should be able to copy and past all if it if you need to test it. I did use network_create_socket_ext() for global.broadcast server but I was just testing different methods. They all seemed to work the same way.
 
Last edited:
Top