network_send_broadcast(socket, port, buffer, size);

参数 描述
socket 所使用的套接字id。
port 服务端所使用的端口。
buffer 待取数据的缓冲区id。
大小 数据大小(字节形式)。

返回: Real(实数)


With this function you can broadcast the data from a buffer locally to a range of IP addresses (for more information on buffers see Reference - Buffers). The range is limited to that of the device running the server, such that if the device has an IP of, then the data will be broadcast over the range 92.168.11.*. The function will return the number of bytes of data sent, or a number less than 0 if the send has failed.

NOTE: This function will only work when used with UDP - your server needs to be TCP and your client needs to have a UDP client socket created with network_create_socket_ext() in order to receive any broadcasts sent from the server.


buffer_seek(broadcast_buffer, buffer_seek_start, 0);
buffer_write(broadcast_buffer, buffer_string, global.ServerName);
network_send_broadcast(server, 6511, broadcast_buffer, buffer_tell(broadcast_buffer));

The above code writes the name string of the current server (stored in "global.ServerName"), then writes it to a binary buffer with the id "broadcast_buffer". This data is then broadcast locally to a range of IPs (the device IP is currently implied as the broadcast base range) to port 6511.