network_send_udp_raw(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 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.
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".