GML problem with Finding Server ip

Discussion in 'Programming' started by Kasra_n, Aug 8, 2019.

  1. Kasra_n

    Kasra_n Member

    Joined:
    Jun 19, 2019
    Posts:
    26
    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
     
  2. chamaeleon

    chamaeleon Member

    Joined:
    Jun 21, 2016
    Posts:
    975
    Over the internet or a local network/LAN?
     
    Kasra_n likes this.
  3. Kasra_n

    Kasra_n Member

    Joined:
    Jun 19, 2019
    Posts:
    26
    local lan network
     
  4. Mert

    Mert Member

    Joined:
    Jul 20, 2016
    Posts:
    388
    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 likes this.
  5. Kasra_n

    Kasra_n Member

    Joined:
    Jun 19, 2019
    Posts:
    26
    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 :( ?
     
  6. Kasra_n

    Kasra_n Member

    Joined:
    Jun 19, 2019
    Posts:
    26
    any idea why this function is not availible for me ? thanks for help
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice