network_send_udp_raw

Send raw buffer data over the network using UDP.

Syntax:

network_send_udp_raw(socket, url, port, buffer, size);


Argument Description
socket The id of the socket to use.
url The url or IP to connect to (a string).
port The port to connect to.
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 data over the network using UDP to a server. The function takes the socket id to connect through, the URL to connect to and the port to use. You must then 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. UDP is "connectionless" in that you don't actually do a connect, you just send a packet directly to an IP, and the server gets incoming data from an IP address and has to deal with it "as is". The data sent is not formatted by GameMaker: Studio 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:

network_send_udp_raw(sock, "www.macsweeneygames.com", 6510, buff, buffer_tell(buff));

The above code will send a raw UDP packet to the server defined by the URL on the port 6510. The data is taken from the buffer indexed in the variable "buff".


Back: Networking
Next: network_destroy
© Copyright YoYo Games Ltd. 2018 All Rights Reserved