gamemaker吧 关注:13,626贴子:94,973
  • 8回复贴,共1

[小窍门]如何获取本机IP地址

只看楼主收藏回复

首先新建一个obj


1楼2017-10-11 13:18回复
    创建事件:
    //Create event
    randomize();
    var a = irandom_range(49152,65535);
    var host = network_create_server(network_socket_udp, a, 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, a, tbuff, buffer_get_size(tbuff));
    network_destroy(tsock);
    buffer_delete(tbuff);
    }
    异步→Networking事件:
    //Networking event
    show_message(string(ds_map_find_value(async_load, "ip")));
    instance_destroy();


    2楼2017-10-11 13:19
    回复
      成功!


      3楼2017-10-11 13:21
      回复
        666666


        IP属地:四川4楼2017-10-11 15:00
        回复


          来自Android客户端5楼2017-10-11 20:20
          回复


            IP属地:上海来自Android客户端6楼2017-10-11 20:58
            收起回复
              好主意


              IP属地:上海来自Android客户端7楼2017-10-11 23:25
              回复
                cmd:你当我是什么


                IP属地:吉林来自Android客户端8楼2017-10-14 10:12
                回复