GML problem with Finding Server ip

Kasra_n

Member
Hi there
my clients needs to find the server ip to connect to it.
how can i achive that without using
Code:
network_create_socket_ext(type, port)
?
how can my make a udp client that sit and listen to a specific port ?, in order to recive a boroadcasted message from the server
 

chamaeleon

Member
Hi there
my clients needs to find the server ip to connect to it.
how can i achive that without using
Code:
network_create_socket_ext(type, port)
?
how can my make a udp client that sit and listen to a specific port ?, in order to recive a boroadcasted message from the server
Over the internet or a local network/LAN?
 

Mert

Member
Noo. It doesn't work like that.

So, a LAN server has two sockets.
  1. Constantly broadcasting a package over network : You send the packages via network_send_broadcast function.
  2. Game server that serves as a base.
First server, sends a dull package over the network, which can include some information like server's name etc. (Remember that these packages automatically have the server's IP address, which we'll use)

In client, you have two sockets as well.
  1. Constantly listening to a UDP package. You'll create a UDP socket with network_create_socket_ext()
  2. Normal game socket that connects to the game server.
In here, your game first listens to the incoming packages from the broadcasting message. This is used for finding the server's IP. In Networking event, you'll start handling the incoming data packages.
Code:
var a = async_load[? "id"];

if (a==broadcastListenerSocket) {

if (async_load[? "type"]==network_type_data) {

var ip, port;
ip = async_load[? "ip"];
port = async_load[? "port"];
//You must also check if this package belongs to our broadcast message.
//Here you can connect with your second socket, to the main game server.

}


}
 

Kasra_n

Member
yeah, tnx for the help, i hadbeen tryed this but
upload_2019-8-9_5-34-59.png
my GM version dont have any network_create_socket_ext function, iam using 1.4, so it mean i cant listen to any broadcasted message from the server :( ?
 
Top