Waltham
0.1.0
|
Common and exclusive API for clients. More...
Modules | |
Common API for both server and client | |
Functions | |
struct wth_connection * | wth_connection::wth_connect_to_server (const char *host, const char *port) |
Connect to a remote Waltham server. More... | |
int | wth_connection::wth_connection_roundtrip (struct wth_connection *conn) |
Make a roundtrip from a client. More... | |
struct wthp_registry * | wth_connection::wth_connection_create_registry (struct wth_connection *conn) |
Creates a new registry using the internal wth_display. More... | |
struct wthp_callback * | wth_connection::wth_connection_sync (struct wth_connection *conn) |
Return a callback using the internal wth_display. More... | |
Common and exclusive API for clients.
These functions are exclusive to a client. They will abort the program if called in the context of a server-side wth_connection. For the common functions, see Common API for both server and client.
struct wth_connection * wth_connect_to_server | ( | const char * | host, |
const char * | port | ||
) |
Connect to a remote Waltham server.
host | The address of the server. |
port | The port of the server. |
This creates a client-side wth_connection, making a connection to a remote Waltham server.
On failure, errno is set.
XXX: This call may block. We should find a way to make this a non-blocking operation, so that if the connection fails to form, we get an error back from read and flush etc.
struct wthp_registry * wth_connection_create_registry | ( | struct wth_connection * | conn | ) |
Creates a new registry using the internal wth_display.
conn | The Waltham connection. |
The returned registry can then be used to retrieve other global objects, using its usual interface.
int wth_connection_roundtrip | ( | struct wth_connection * | conn | ) |
Make a roundtrip from a client.
conn | The Waltham connection. |
This is a helper for creating a wthp_callback object by sending wth_display.sync request, and waiting for the callback to trigger. As such, it is only usable for clients.
This call blocks indefinitely until the roundtrip completes or the connection fails. It will flush outgoing and dispatch incoming messages until it returns.
On failure, use wth_connection_get_error() to inspect the error.
If blocking indefinitely is not desireable or you want to be able to process other file descriptors in the mean time, you have to write your own roundtrip implementation using the public API.
struct wthp_callback * wth_connection_sync | ( | struct wth_connection * | conn | ) |
Return a callback using the internal wth_display.
conn | The Waltham connection. |
The returned callback will emit a 'done' event once the server has seen all preceding requests.