-
Notifications
You must be signed in to change notification settings - Fork 1
Protocol
LuaRPC servers listen on an opened connection for incoming remote procedure requests. At the moment, only one connection is accepted at a time, as LuaRPC runs as single threaded Lua code. Multiple servers may run on a single computer, as long as they aren’t using the same transport connection to communicate over.
When a client opens a connection, it first exchanges a negotiation packet with the server. This is used to ensure that both are running the same version, and is used to select whether numbers will be sent as integers or floats, what the size is of the Lua number type, and what byte ordering to use. If negotiation is successful, various remote procedure calls can be issued from the client to the server. Remote function calls may be made, where return values are serialized over the connection and returned to the client. In addition, one can set variables on the server or get values from remote variables.
Most built-in Lua types can be serialized over the connection:
Type | Exceptions/Notes | |
---|---|---|
numbers | ||
strings | ||
booleans | ||
tables | no circular references | |
functions | no upvalues, if endianness or numeric type differ, patching is needed | |
nil |
session:
“LRFP” - “lua remote function protocol” protocol version
u8 -
function_call, function_call, …
function_call:
string - name of function number of input variables
u32 -
var,var,… — input arguments
return_value: - normal return value number of output variables
u8 (0)
u32 -
var,var,…
return_value:
u8 (1) - error return error code
u32 -
string — error string
var:
u8 — type
data…
string:
u32 - length string bytes
u8,u8,u8… -