• 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!

GameMaker GameMaker not picking the correct network to broadcast message

R

Rabid

Guest
In my game I need to get the local network IP of the computer that is running the game, and for that purpose I have the following code:

Code:
// Create event
randomize();
var random_port = irandom_range(49152,65535);
host = network_create_server(network_socket_udp, random_port, 5);

if ( host < 0 ) {
   show_message("Failed to create a broadcast server");
   game_end();
} else {
   var tsock = network_create_socket(network_socket_udp);
   var tbuff = buffer_create(32, buffer_fixed, 1);
   buffer_fill(tbuff, 0, buffer_bool, 0, 32);
   network_send_broadcast(tsock, random_port, tbuff, buffer_get_size(tbuff));
   network_destroy(tsock);
   buffer_delete(tbuff);
}
Code:
/// Async network event
global.game_ip = string(async_load[? "ip"]);
instance_destroy();
I've manually set up my local network IP to be 192.168.1.150, but when I run the code above, I get the IP 169.254.51.115.

Because I wasn't expecting such IP, I ran the ipconfig/all command (on Windows) and I got the following output (I've translated the output because my computer is in another language, and I've deleted the information that isn't relevant to this):
Code:
Ethernet adapter:

   Specific dns for this connection. . : Home
   Description . . . . . . . . . . . . . . . : Realtek PCIe GBE Family Controller
   [...]
   IPv4 address. . . . . . . . . . . . . . : 192.168.1.150(Preferred)
   Subnet Mask . . . . . . . . . . . . : 255.255.255.0
   Default gateway . . . . . : 192.168.1.1
   DHCP server . . . . . . . . . . . . . . : 192.168.1.1
   DNS Servers. . . . . . . . . . . . . . : fe80::1%13
                                      1.1.1.1
                                      1.0.0.1

Ethernet Npcap Loopback Adapter:

   Specific dns for this connection. . :
   Description . . . . . . . . . . . . . . . : Npcap Loopback Adapter
   IPv4 automatic configuration address: 169.254.51.115(Preferred)
   Subnet mask . . . . . . . . . . . . : 255.255.0.0
   Default gateway . . . . . :
   DNS Servers. . . . . . . . . . . . . . : fec0:0:0:ffff::1%1
                                             fec0:0:0:ffff::2%1
                                           fec0:0:0:ffff::3%1
So, from my understanding point of view, Game Maker is getting the Ethernet Npcap Loopback Adapter instead of the regular ethernet adapter.

I could delete the Npcap Loopback adapter, but what if a user has wifi and ethernet connection?

Is there a way for Game Maker to choose one or another adapter?

In case the previous answer is no, is there a workaround for this to avoid getting the Npcap loopback adatper?
 

Kepons

Lost The Bet
I don't have a lot of experience in networking but I think your machine uses the loopback adapter because you're broadcasting to yourself (the regular Ethernet interface would be used if you were trying to send data to another machine).

You might want to look up how to send a request to a site like whatismyipaddress.com from GameMaker, although I'm not sure that would accomplish exactly what you're trying to do.
 
R

Rabid

Guest
The thing is that, sometimes, when I start Game Maker real fast after booting up my computer, the ethernet interface is picked up and it shows correctly the IP (192.168.1.150), so I'm not sure if it is a problem of broadcasting to myself or not.

Im not sure if pinging an external site would help because in the async load would come the IP of the external site, and I need the IP from the same machine the game is running.

Which means I need to receive a request I myself sent. That's what the broadcast does... If it picked up the correct interface! Haha
 
Top