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

参数 描述
socket 所使用的套接字id。
url 待连接的URL或IP(字符串形式)。
port 待连接的端口。
buffer 待取数据的缓冲区id。
大小 数据大小(字节形式)。

返回: Real(实数)


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(sock, "", 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".