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 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.
network_send_udp(socket, url, port, buffer, size);
|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.|
network_send_udp(sock, "www.macsweeneygames.com", 6510, buff, buffer_tell(buff));
The above code will send a 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".