ark::python::CommsServer
Defined in header “ark/python/stages/comms_server.hh”.
This is a server used to communicate with the Python process. It is kept as simple as possible to reduce the burden on Python. Previously, we made use of websockets, but the overhead on the Python side was extreme (often 100ms+ to send 20MB of data locally).
This essentially just establishes a connection and then sends/receives messages that are prefixed with a 2 byte synchronization sequence, a 4 byte length, and then the payload.
Methods
-
CommsServer()
Constructor. Initializes the comms server and binds to a port. -
comms::NetworkAddress address()
Returns the address this server is bound to. -
bool client_connected()
Returns true if the client is connected or false. -
void poll(std::chrono::nanoseconds timeout)
Polls the server, handling reading and writing data as appropriate. -
std::vector< core::ByteBuffer > pop_all()
Returns the queue of read messages, clearing it out locally. -
void write(const core::ByteBuffer & data)
Writes the given byte buffer to the remote client, as a single message. -
void disconnect()
Forces a disconnect. This will drop the connection to the remote client.