libamxb
4.8.2
Bus Agnostic C API
|
Functions | |
int | amxb_connect (amxb_bus_ctx_t **ctx, const char *uri) |
Create a bus connection. More... | |
int | amxb_connect_intf (amxb_bus_ctx_t **ctx, const char *uri, const char *intf) |
Create a bus connection. More... | |
int | amxb_listen (amxb_bus_ctx_t **ctx, const char *uri) |
Create a listen socket. More... | |
int | amxb_accept (amxb_bus_ctx_t *listen_ctx, amxb_bus_ctx_t **accepted_ctx) |
Accepts an incomming connection request. More... | |
int | amxb_disconnect (amxb_bus_ctx_t *ctx) |
Disconnects a bus connection. More... | |
void | amxb_free (amxb_bus_ctx_t **ctx) |
Frees allocated memory. More... | |
amxb_bus_ctx_t * | amxb_find_uri (const char *uri) |
Find the bus context for a given uri. More... | |
amxc_array_t * | amxb_list_uris (void) |
List all open connections by their uri. More... | |
int | amxb_get_fd (const amxb_bus_ctx_t *const ctx) |
Get the connection file descriptor. More... | |
int | amxb_read (const amxb_bus_ctx_t *const ctx) |
Reads data from the file descriptor. More... | |
int | amxb_read_raw (const amxb_bus_ctx_t *const ctx, void *buf, size_t count) |
Attempts to read up to count bytes from the file descriptor into the buffer starting at buf. More... | |
static void | amxb_set_access (amxb_bus_ctx_t *const ctx, uint32_t access) |
Sets the access method. More... | |
static bool | amxb_is_listen_socket (const amxb_bus_ctx_t *const ctx) |
Checks if the provided context is a listen socket. More... | |
static bool | amxb_is_data_socket (const amxb_bus_ctx_t *const ctx) |
Checks if the provided context is a data socket. More... | |
int amxb_accept | ( | amxb_bus_ctx_t * | listen_ctx, |
amxb_bus_ctx_t ** | accepted_ctx | ||
) |
Accepts an incomming connection request.
To be able to accept incoming connection requests a listen socket must be created first. A listen socket can be created using amxb_listen.
This function is typically used from within an event loop callback function, and should be called when data is available on the created listen socket.
listen_ctx | The listen connection context |
accepted_ctx | The accepted connection |
Definition at line 268 of file amxb_ba_connect.c.
int amxb_connect | ( | amxb_bus_ctx_t ** | ctx, |
const char * | uri | ||
) |
Create a bus connection.
Connects to a bus using a uri.
The uri must be strictly compliant with RFC 3986. The scheme of the uri refers to the backend that is used. The other parts of the uri are used by the backend to create a connection
Searches a bus backend using the scheme of the uri, if found creates a connection to the bus and allocates a connection context.
Multiple connections can be created to different busses.
ctx | The connection context |
uri | The connection uri, compliant with RFC 3986 |
Definition at line 235 of file amxb_ba_connect.c.
int amxb_connect_intf | ( | amxb_bus_ctx_t ** | ctx, |
const char * | uri, | ||
const char * | intf | ||
) |
Create a bus connection.
Connects to a bus using a uri and a network interface name or id (aka zone id).
This function works exactly the same as Bus Connections, the interface name will be added to the host part of the uri prefixed with a %.
ctx | The connection context |
uri | The connection uri, compliant with RFC 3986 |
Definition at line 197 of file amxb_ba_connect.c.
int amxb_disconnect | ( | amxb_bus_ctx_t * | ctx | ) |
Disconnects a bus connection.
Closes the connection to a bus that was previously created with Bus Connections.
After calling this function the connection is closed and can not be used any more.
ctx | the connection context |
Definition at line 303 of file amxb_ba_connect.c.
amxb_bus_ctx_t* amxb_find_uri | ( | const char * | uri | ) |
Find the bus context for a given uri.
If a connection already exists for a uri, the bus_ctx can be retrieved using this function
uri | The connection uri |
Definition at line 360 of file amxb_ba_connect.c.
void amxb_free | ( | amxb_bus_ctx_t ** | ctx | ) |
Frees allocated memory.
The allocated memory for the connection context is freed.
The connection is automatically disconnected if it is still connected.
The pointer to the connection context is reset to NULL
ctx | the connection context that was created with Bus Connections |
Definition at line 339 of file amxb_ba_connect.c.
int amxb_get_fd | ( | const amxb_bus_ctx_t *const | ctx | ) |
Get the connection file descriptor.
Gets the file descriptor of the connection context. Use this function to add the file descriptor to your event loop.
ctx | the connection context |
Definition at line 375 of file amxb_ba_connect.c.
|
inlinestatic |
Checks if the provided context is a data socket.
Data sockets are used to transfer messages between applications.
ctx | the connection context |
Definition at line 397 of file amxb_connect.h.
|
inlinestatic |
Checks if the provided context is a listen socket.
With a listen socket connection, incoming connection requests can be handled. Using listen sockets it is possible to create an E2E connection between different applications, without the need for a broker/dispatcher process.
Depending on the back-end and bus system used, this feature may not be available.
ctx | the connection context |
Definition at line 379 of file amxb_connect.h.
amxc_array_t* amxb_list_uris | ( | void | ) |
List all open connections by their uri.
returns an amxc_array_t containing const char * of all connect uris.
Definition at line 370 of file amxb_ba_connect.c.
int amxb_listen | ( | amxb_bus_ctx_t ** | ctx, |
const char * | uri | ||
) |
Create a listen socket.
Creates a listen socket using a specific back-end.
The uri must be strictly compliant with RFC 3986. The scheme of the uri refers to the backend that is used. The other parts of the uri are used by the backend to create a connection
Searches a bus backend using the scheme of the uri, if found and the back-end supports the creation of a listen socket, a listen socket is created.
Multiple listen sockets can be created using different back-ends.
When a listen socket is created, its file descriptor should be added to the event loop, when data is available on that file descriptor (incoming connection), the callback function in the event loop should call amxb_accept
ctx | The connection context |
uri | The listen uri, compliant with RFC 3986 |
Definition at line 239 of file amxb_ba_connect.c.
int amxb_read | ( | const amxb_bus_ctx_t *const | ctx | ) |
Reads data from the file descriptor.
Reads data from the file descriptor of the connection context.
Typically the backend parses the received data and dispatches to the correct callbacks if needed.
This function is typically called whenever your eventloop detects that data is available for read on the connection context's file descriptor.
ctx | the connection context |
Definition at line 392 of file amxb_ba_connect.c.
int amxb_read_raw | ( | const amxb_bus_ctx_t *const | ctx, |
void * | buf, | ||
size_t | count | ||
) |
Attempts to read up to count bytes from the file descriptor into the buffer starting at buf.
Reads data from the file descriptor of the connection context, and puts the read data in the provided bufffer, up to the given count bytes.
The data received is put in the buffer as is, not parsing is done.
This function is typically called whenever your eventloop detects that data is available for read on the connection context's file descriptor.
ctx | the connection context |
buf | pointer to a memory block where data can be put |
count | maximum number of bytes that can be put in the memory block |
Definition at line 408 of file amxb_ba_connect.c.
|
inlinestatic |
Sets the access method.
ctx | the connection context |
access | the access method, must be one of AMXB_PUBLIC, AMXB_PROTECTED |
Definition at line 355 of file amxb_connect.h.