The TCP-socket-based transport layers a very simple protocol on top of ordinary TCP sockets:
See also
The following configuration options are accepted by the TCP-socket-based transport:
Name Type Comment
+ transport
+-- socket
+---- host string Name of host running server
+---- port uint Port on which server listens
+---- server { 0, 1, auto } Act as server?
+---- tcpnodelay boolean Implementation detail
Server | Client | |
---|---|---|
Default address | localhost | 0.0.0.0 |
Default port | 55555 | 55555 |
It is possible to operate in “auto” mode instead of client or server mode. In that case the following actions are performed:
Note
This “auto” mode can only work properly for connections on a single computer: if a host other than the local host was used, it would be impossible to act as server when required.
In special cases, “auto” may still be useful for setups distributed over multiple computers but these cases require a detailed understanding of the above protocol and should generally be avoided.
The following messages are exchanged:
Name | Size [bytes] | Content | Comment |
---|---|---|---|
mzero | 4 | four 0 bytes | only used during handshake |
msize | 4 | size of payload in mpayload | little-endian |
mpayload | variable | payload blob | size is specified by previous msize |
Note
The handshake part of the protocol (explained below) is required to prevent the following scenario from happening:
From the client’s perspective, the protocol consist of
The server establishes a listening TCP socket on the configured port. When a connection is accepted, the server continues to accept other connections and concurrently performs the following protocol on the new connection:
# handshake
S -> C 0x00 0x00 0x00 0x00 0x00
# established
C -> S 0x23 0x00 0x00 0x00 # 35-byte payload follows
C -> S 0x12 0x34 0x56 0x78 0x9a ... # 35-byte payload blob
C -> S 0x03 0x00 0x00 0x00 # 3-byte payload follows
C -> S 0x12 0x34 0x56 # 3-byte payload blob
...
# shutdown
C -> S end-of-file
S -> C end-of-file
Language | File(s) |
---|---|
C++ | “0.11” branch of https://code.cor-lab.org/git/rsb.git.cpp at src/rsb/transport/socket |
Java | “0.11” branch of https://code.cor-lab.org/git/rsb.git.java at src/rsb/transport/socket |
Python | /../rsb-python/rsb/transport/socket/__init__.py |
Common Lisp | “0.11” branch of https://code.cor-lab.org/git/rsb.git.cl at src/transport/socket |