Send a GameMaker: Studio formatted packet of data over the network.


GML Code Example

network_send_packet(socket, buffer, size);

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

Returns: Real


With this function you can send a data "packet" through the network. The function takes the socket id to connect through and then you must supply the buffer id which contains the data to be sent (for more information on buffers see Reference - Buffers) and finally the size (in bytes) of the data packet. Packets sent with this function are formatted such that the GameMaker: Studio game receiving the data can correctly "split" the packets correctly, and the function will return the number of bytes of data sent, or a number less than 0 if the send has failed. It is worth noting that the final size of the data being sent that is returned by this function will also include the GameMaker header information, which is an additional 12 bytes.


GML Code Example

buff = buffer_load("player_save.dat");
 network_send_packet(sock, buff, buffer_get_size(buff));

The above information loads a previously saved buffer data into memory and returns the buffer id to be stored in the variable "buff". This complete buffer is then send as a packet over the network using the socket identified by the variable "sock".

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