Module net
The net library
Exposes various structs, constants, and functions for passing messages
-
stream:readint ()
-
Read an integer from the stream
Returns:
number
The number read from the stream
-
stream:readdouble ()
-
Read double percision float from the stream
Returns:
number
The number read from the stream
-
stream:readdata (size)
-
Read some data from the stream
Parameters:
- size
number
The size of the data to read from the stream
Returns:
string
The data read from the stream
-
stream:readstring ()
-
Read a string from the stream
Returns:
string
The string read from the stream
-
stream:writeint (i)
-
Write an integer to the stream
Parameters:
- i
number
The integer to write to the stream
-
stream:writedouble (d)
-
Write a double percision float to the stream
Parameters:
- d
number
The number to write to the stream
-
stream:writedata (d)
-
Write some data to the stream
Parameters:
- d
number
The number to write to the stream
Returns:
number
The number of bytes written to the stream
-
stream:writestring (s)
-
Write a string to the stream
Parameters:
- s
string
The string to the stream
-
socket:bind (where)
-
Parameters:
- where
string
Where to connect this socket to
Usage:
local s = net.newsocket()
s:bind("127.0.0.1")
s:receive("ping",function(stream)
print(instream:readstring())
end)
local c = net.newsocket()
c:connect("127.0.0.1")
-
receive (message, callback)
-
Parameters:
- message
string
The message to bind this function to
- callback
function
The function to call when this message is received
-
newsocket ()
-
domain:
Returns:
net.socket
-
socket
-
domain:
Fields: