1
\$\begingroup\$

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:

// 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);
}
/// 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):

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?

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.