libamxp
1.4.0
Patterns C Implementation
|
Functions | |
int | amxp_connection_add (int fd, amxp_fd_cb_t reader, const char *uri, uint32_t type, void *priv) |
Adds a file descriptor (fd) to the list of fds that must be watched. More... | |
int | amxp_connection_wait_write (int fd, amxp_fd_cb_t can_write_cb) |
Adds a watcher to check if a fd is ready for write. More... | |
int | amxp_connection_remove (int fd) |
Removes the fd from the connection list. More... | |
amxp_connection_t * | amxp_connection_get (int fd) |
Gets the connection data for a file descriptor. More... | |
amxp_connection_t * | amxp_connection_get_first (uint32_t type) |
Gets the first connection of the given type. More... | |
amxp_connection_t * | amxp_connection_get_next (amxp_connection_t *con, uint32_t type) |
Gets the next connection data for a file descriptor. More... | |
int | amxp_connection_set_el_data (int fd, void *el_data) |
Sets event-loop data. More... | |
amxc_llist_t * | amxp_connection_get_connections (void) |
Get a list of the current connections of the application. More... | |
amxc_llist_t * | amxp_connection_get_listeners (void) |
Get of the current listen sockets of the application. More... | |
int amxp_connection_add | ( | int | fd, |
amxp_fd_cb_t | reader, | ||
const char * | uri, | ||
uint32_t | type, | ||
void * | priv | ||
) |
Adds a file descriptor (fd) to the list of fds that must be watched.
This function will trigger the signal "connection-added" or "listen-added" depending on the type given.
If the type given is "AMXP_CONNECTION_LISTEN" the fd will be added to the list of listen fds and the signal "listen-added" is triggered.
A callback function must be given. This callback function is called whenever data is available for read.
fd | the fd that must be watched |
reader | the read callback function, is called when data is available for read |
uri | (option, can be NULL) a uri representing the fd |
type | one of AMXP_CONNECTION_BUS, AMXP_CONNECTION_LISTEN, AMXP_CONNECTION_CUSTOM |
priv | private data, will be passed to the callback function |
Definition at line 129 of file amxp_connections.c.
amxp_connection_t* amxp_connection_get | ( | int | fd | ) |
Gets the connection data for a file descriptor.
Searches the connection data for the given fd. The connection data is stored in the amxp_connection_t structure.
fd | the fd associated with the connection |
Definition at line 212 of file amxp_connections.c.
amxc_llist_t* amxp_connection_get_connections | ( | void | ) |
Get a list of the current connections of the application.
At runtime an application can be connected to a number of sockets. This function retrieves a list of sockets the app is connected to.
Definition at line 279 of file amxp_connections.c.
amxp_connection_t* amxp_connection_get_first | ( | uint32_t | type | ) |
Gets the first connection of the given type.
type | one of AMXP_CONNECTION_BUS, AMXP_CONNECTION_LISTEN, AMXP_CONNECTION_CUSTOM |
Definition at line 225 of file amxp_connections.c.
amxc_llist_t* amxp_connection_get_listeners | ( | void | ) |
Get of the current listen sockets of the application.
While an application is running, it can have a list of of open listen sockets that other applications can connect to.
Definition at line 283 of file amxp_connections.c.
amxp_connection_t* amxp_connection_get_next | ( | amxp_connection_t * | con, |
uint32_t | type | ||
) |
Gets the next connection data for a file descriptor.
con | starting point reference |
type | one of AMXP_CONNECTION_BUS, AMXP_CONNECTION_LISTEN, AMXP_CONNECTION_CUSTOM |
Definition at line 239 of file amxp_connections.c.
int amxp_connection_remove | ( | int | fd | ) |
Removes the fd from the connection list.
This function triggers the signal "connection-deleted".
Event-loop implementations can connect to this signal and when it is triggered remove the watchers for the given fd.
fd | the fd that must be watched |
Definition at line 186 of file amxp_connections.c.
int amxp_connection_set_el_data | ( | int | fd, |
void * | el_data | ||
) |
Sets event-loop data.
This function is typically used by event-loop implementations to set event-loop specific data for the connection
fd | the fd that must be watched |
el_data | some event loop data |
Definition at line 260 of file amxp_connections.c.
int amxp_connection_wait_write | ( | int | fd, |
amxp_fd_cb_t | can_write_cb | ||
) |
Adds a watcher to check if a fd is ready for write.
It can happen that a fd is not ready for write. Most of the time the write fails with error code EAGAIN or EWOULDBLOCK. Whenever this happens it is possible to indicate to the event-loop implementation that the fd must be watched and a callback must be called as soon as the fd is available again for writing.
Another use case for this function is a asynchronous connect.
This function will trigger the signal "connection-wait-write". Event-loop implementations can connect to this signal, to add a watcher for the fd.
Typically when the fd is ready for write the watcher is removed.
fd | the fd that must be watched |
can_write_cb | a callback function called when the socket is available for write |
Definition at line 161 of file amxp_connections.c.