1. Hello Guest! It's with a heavy heart that we must announce the removal of the Legacy GMC Archive. If you wish to save anything from it, now's the time! Please see this topic for more information.
    Dismiss Notice

OFFICIAL Beginners Guide To Networking

Discussion in 'Announcements' started by rmanthorp, Oct 11, 2019.

  1. rmanthorp

    rmanthorp YoYo Games Staff Admin YYG Staff

    Joined:
    Apr 15, 2016
    Posts:
    309
    Our latest tech blog is our Beginners Guide To Networking. Check it out:

    https://www.yoyogames.com/blog/529/beginners-guide-to-networking
     
  2. FrostyCat

    FrostyCat Member

    Joined:
    Jun 26, 2016
    Posts:
    4,684
    Copywriting note: In future articles featuring code, watch out for curly double quotes like this seeping in due to AutoCorrect:
    Code:
    buffer_write(t_buffer , buffer_string,”Hello”);
    
    The GMS IDE recognizes only straight double quotes, and will not accept strings delimited this way.
     
    rmanthorp, KPJ and Cloaked Games like this.
  3. Neptune

    Neptune Member

    Joined:
    Jun 21, 2016
    Posts:
    1,042
    Very cool, thanks!
     
  4. Arconious

    Arconious Member

    Joined:
    Jun 20, 2016
    Posts:
    38
    Thanks for the article! In the "Detect Client Connection" section, I believe the example code for the disconnect handling is erroneous and should be
    Code:
    ds_list_delete(socketlist, ds_list_find_index(socketlist, sock));
     
  5. FlameRooster

    FlameRooster Member

    Joined:
    Feb 14, 2017
    Posts:
    138
    Love these networking articles!

    Will there be articles on client prediction and anti hack? Or are those topics a bit too advanced?
     
  6. Zhanghua

    Zhanghua Member

    Joined:
    Aug 3, 2017
    Posts:
    172
    There is a question on the data recieving....
    Tcp socket has two type, one for listenning and one for data transferring.
    Code shoud like this?
    Code:
    var ev_id = ds_map_find_value(async_load, "id");
    var type = ds_map_find_value(async_load, "type");//
    var ip    = ds_map_find_value(async_load, "ip");//
    if( lstn == ev_id ){//check whether the listen socket
        switch(type){
            case network_type_connect:
            case network_type_non_blocking_connect:
                var clnt = ds_map_find_value(async_load, "socket");//Save the data transferring socket
                show_debug_message(string(ip)+":"+string(port)+"Conneted-----------" + string(clnt));
                Client_Info[? clnt] = "";
                Client_Ids[? clnt]  = baseid++;
            break;
            case network_type_disconnect:
                var clnt = ds_map_find_value(async_load, "socket");
                show_debug_message(string(ip)+":"+string(port)+"Disconneted-----------" + string(clnt));
                ds_map_delete(Client_Info,clnt);
                ds_map_delete(Client_Ids,clnt);
            break;
        }
    }
    else{//Data from client
        if( undefined != ds_map_find_value(Client_Ids,ev_id) ){
            var clnt = ev_id;
            switch(type){
                case network_type_data:
                    var buff = ds_map_find_value(async_load, "buffer");
                    var size = ds_map_find_value(async_load, "size");
                    var str  = buffer_read(buff,buffer_string);
                    var cid  = Client_Ids[? clnt];
                    Client_Info[? clnt] = string(ip)+":"+string(port)+"="+str;
                    show_debug_message("Tcp Data" + string(cid) + "=" +str);
                break;
            }       
        }
    }
    
    
    
     
  7. Zhanghua

    Zhanghua Member

    Joined:
    Aug 3, 2017
    Posts:
    172
    Is there an error of Mark Alexander‘s paper ????
    So I can't translate this paper with the corespond doubt.....
    Cause in my project, I realized this by method like the replied post above.


    The recent essays on BLEND MODE have translated into chinese:
    https://www.bilibili.com/read/cv3806331
    https://www.bilibili.com/read/cv3807613
     
  8. Ablationer

    Ablationer Member

    Joined:
    Dec 30, 2017
    Posts:
    6
    I'm having an issue with this example where I can use it to connect to a network in local, however if someone else tries to connect over the internet, it doesn't work. I've tried changing global.connectip to my actual public address, but nothing.
     
  9. Zhanghua

    Zhanghua Member

    Joined:
    Aug 3, 2017
    Posts:
    172
    NAT
     

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