This package includes the Minitel service, in apps/svc-minitel.lua, and the net library, in libs/minitel.lua.
The Minitel service provides packet sending and receiving abilities.
The net library provides an easy way of interacting with the minitel service, and implements higher-level features of the stack.
Place libs/minitel.lua into
Due to how KittenOS's security model works, you have to initialise the library in an unusual way:
``` local minitel = neo.requireAccess("x.svc.minitel","minitel daemon access") local event = require("event")(neo)
local net = require("minitel")(event,minitel) ```
This gives access to the event API and Minitel service to the net library.
Being a direct port of the OpenOS version, the API is the same.
net.genPacketID() - returns a string of random data
net.usend(host, port, data, pid) - Sends an unreliable packet to host on port containing data, optionally with the packet ID pid.
net.rsend(host, port, data, block) - Sends a reliable packet to host on port containing data. If block is true, don't wait for a reply.
net.send(host, port, data) - Sends data reliably and in order to host on port.
net.open(to,port) - Establishes a stream to host on port and returns a stream object
net.listen(port) - Waits for another node to establish a stream, and returns the stream object.
stream:write(data) - Sends data to the node at the other end of the stream
stream:read(length) - Reads data from the stream, up to length bytes.
stream:close() - Ends the stream and prevents further writing.
net.mtu = 4096 - The maximum length of the data portion of a packet for net.send
net.streamdelay = 60 - The time, in seconds, net.open will wait for a response while trying to establish a connection.
net.minport = 32768 - The lowest port net.listen will allocate to a new connection.
net.maxport = 65535 - The highest port net.listen will allocate to a new connection.