|  Developer
Updated on November 14, 2021

request()

  • Request to receive datagram. Specified script will be called when datagram will be received. Note that only one datagram will be received for a single request() call. Multiple requests may be scheduled.
Edit
Parameter Type Required Description
handle int + Connection handle
callback string + Plugin script file that will be called with recieved data
user_data string Any data which will be passed to callback
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
Nothing
Edit
Parameter Type Description
event string
data.handle int Connection handle
data.user_data string User data passed to request() call
data.datagram string Received datagram
Edit
				
					local params = ...

local network = require("network")

if params.event == "request" then
    print(params.data.user_data .. params.data.datagram)
    return
end

local handle = network.udp();
network.setsockname(handle, "*", "8021")
network.sendto(handle, "Is there anyone?", "192.168.1.255", "8021")
network.request(handle, "this_script_name", "Found: ")