network_send_broadcast

Broadcast data to a range of IPs.

Syntax:

GML Code Example

network_send_broadcast(socket, port, buffer, size);


Argument Description
socket The id of the socket to use.
port The port that the server will use.
buffer The id of the buffer to get the data from.
size The size (in bytes) of the data.


Returns: Real


Description

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 92.168.11.130, 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.


Example:

GML Code Example

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.





No Examples Submitted

Does this page need better examples? Be the first to Submit

No Edits Suggested

Is this page unclear or not descriptive enough? Suggest an edit to the page and with enough upvotes your changes will be made.

No Questions Have Been Ask

Do you have a question about this page? Ask it Here