Skip to content
jsnyder edited this page Sep 13, 2010 · 4 revisions

Lua RPC Protocol (draft)

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.

Supported Types

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

Initial Negotiation

Main Protocol (currently outdated)

session:
LRFP- “lua remote function protocol”
u8 -
protocol version
function_call, function_call, …

function_call:
string - name of function
u32 -
number of input variables
var,var,… — input arguments

return_value: - normal return value
u8 (0)
u32 -
number of output variables
var,var,…

return_value:
u8 (1) - error return
u32 -
error code
string — error string

var:
u8 — type
data…

string:
u32 - length
u8,u8,u8… -
string bytes

Clone this wiki locally