|  Developer
Updated on November 14, 2021

receivefrom()

  • Works exactly as the method, except it returns address and port as extra return values (and is therefore slightly less efficient).
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
string Sender address
string Sender port
Edit
				
					local params = ...

local network = require("network")
if params.event == "network" and params.data.event_type == network.event_types.io_activity.type_name then
    if params.data.event.io_activity_type == network.event_types.io_activity.IN then
        data, address, port = network.receivefrom(params.data.event.handle)
        print("Message: " .. data)
        print("Address: " .. address)
        print("Port: " .. port)
    end
    return
end