receive()
- Receives a datagram from the UDP socket. If the UDP socket is connected, only datagrams coming from the peer are accepted. Otherwise, the returned datagram can come from any host. If there are more than size bytes available in the datagram, the excess bytes are discarded. If there are less then size bytes available in the current datagram, the available bytes are returned.
Edit
Parameter | Type | Required | Description |
---|---|---|---|
handle | int | + | Connection handle |
size | int | – | Maximum size of the datagram to be retrieved. If omitted, the maximum datagram size is used (which is currently limited by the implementation to 8192 bytes). |
Edit
Type | Description |
---|---|
string | Received datagram |
Edit
local params = ...
local network = require("network")
if params.event == "network" and params.data.event_type == "io_activity" then
if params.data.event.io_activity_type == "IN" then
print("Message: " .. network.receive(params.data.event.handle))
end
return
end