network_send_raw

Syntax:

network_send_raw(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


Description

With this function you can send a "raw" 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. The data sent is not formatted by GameMaker Studio 2 in any way and the receiving devices will get the data as a stream which means you will have to handle it yourself. The function will return the number of bytes of data sent, or a number less than 0 if the send has failed.


Example:

buff = buffer_load("player_save.dat");
network_send_raw(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 raw data packet over the network using the socket identified by the variable "sock".