An application can create as many connection sets as it wishes, but most applications will need only one. In most cases, all connections with the same protocol role can be placed into the same connection set.
Defines | |
#define | MRPC_VERSION_CODE() |
Get the version code for the miniRPC headers the application was compiled against. | |
#define | MRPC_MAKE_VERSION_CODE(major, minor, revision) |
Make a version code from the specified components. | |
#define | MRPC_VERSION_MAJOR(code) |
Extract a major version number from a version code. | |
#define | MRPC_VERSION_MINOR(code) |
Extract a minor version number from a version code. | |
#define | MRPC_VERSION_REVISION(code) |
Extract a revision number from a version code. | |
Functions | |
int | mrpc_version_code (void) |
Get the version code for the miniRPC library the application is running against. | |
int | mrpc_conn_set_create (struct mrpc_conn_set **new_set, const struct mrpc_protocol *protocol, void *set_data) |
Create a connection set. | |
void | mrpc_conn_set_ref (struct mrpc_conn_set *set) |
Increment the refcount of a connection set. | |
void | mrpc_conn_set_unref (struct mrpc_conn_set *set) |
Decrement the refcount of a connection set. | |
int | mrpc_set_accept_func (struct mrpc_conn_set *set, mrpc_accept_fn *func) |
Set the function to be called when a new connection arrives on a listening socket. | |
int | mrpc_set_disconnect_func (struct mrpc_conn_set *set, mrpc_disconnect_fn *func) |
Set the function to be called when a connection is closed for any reason. | |
int | mrpc_set_ioerr_func (struct mrpc_conn_set *set, mrpc_ioerr_fn *func) |
Set the function to be called when a connection encounters an I/O error. | |
int | mrpc_set_max_buf_len (struct mrpc_conn_set *set, unsigned len) |
Set the maximum length of a received message payload. | |
int | mrpc_set_listen_backlog (struct mrpc_conn_set *set, unsigned backlog) |
Set the number of accepted connections that can be waiting in the kernel. | |
int | mrpc_set_accept_backoff (struct mrpc_conn_set *set, unsigned ms) |
Set the number of milliseconds to back off if accept() fails. | |
int | mrpc_set_keepalive_enabled (struct mrpc_conn_set *set, int enabled) |
Set whether keepalives will be enabled on new connections. | |
int | mrpc_set_keepalive_parameters (struct mrpc_conn_set *set, unsigned idletime, unsigned count, unsigned interval) |
Set TCP keepalive parameters for new connections. |
#define MRPC_VERSION_CODE | ( | ) |
Get the version code for the miniRPC headers the application was compiled against.
#define MRPC_MAKE_VERSION_CODE | ( | major, | |||
minor, | |||||
revision | ) |
Make a version code from the specified components.
major | The major release number | |
minor | The minor release number | |
revision | The revision number |
#define MRPC_VERSION_MAJOR | ( | code | ) |
Extract a major version number from a version code.
code | The version code |
#define MRPC_VERSION_MINOR | ( | code | ) |
Extract a minor version number from a version code.
code | The version code |
#define MRPC_VERSION_REVISION | ( | code | ) |
Extract a revision number from a version code.
code | The version code |
int mrpc_version_code | ( | void | ) |
Get the version code for the miniRPC library the application is running against.
int mrpc_conn_set_create | ( | struct mrpc_conn_set ** | new_set, | |
const struct mrpc_protocol * | protocol, | |||
void * | set_data | |||
) |
Create a connection set.
[out] | new_set | The resulting connection set, or NULL on error |
protocol | Protocol role definition for connections in this connection set | |
set_data | An application-specific cookie for this connection set |
set_data
is NULL, set the application-specific pointer to the connection set handle returned in new_set
.
void mrpc_conn_set_ref | ( | struct mrpc_conn_set * | set | ) |
Increment the refcount of a connection set.
set | The connection set |
void mrpc_conn_set_unref | ( | struct mrpc_conn_set * | set | ) |
Decrement the refcount of a connection set.
set | The connection set |
After the set's refcount reaches zero, the application must not start any additional dispatchers or create any connections against the set. However, if the set still has listening sockets, new connections may continue to arrive. In addition, the application should continue to dispatch events against the set (if it is doing its own dispatching) until the dispatcher functions return ENXIO.
int mrpc_set_accept_func | ( | struct mrpc_conn_set * | set, | |
mrpc_accept_fn * | func | |||
) |
Set the function to be called when a new connection arrives on a listening socket.
set | The connection set to configure | |
func | The accept function |
set
.
int mrpc_set_disconnect_func | ( | struct mrpc_conn_set * | set, | |
mrpc_disconnect_fn * | func | |||
) |
Set the function to be called when a connection is closed for any reason.
set | The connection set to configure | |
func | The disconnect function, or NULL for none |
int mrpc_set_ioerr_func | ( | struct mrpc_conn_set * | set, | |
mrpc_ioerr_fn * | func | |||
) |
Set the function to be called when a connection encounters an I/O error.
set | The connection set to configure | |
func | The ioerr function, or NULL for none |
int mrpc_set_max_buf_len | ( | struct mrpc_conn_set * | set, | |
unsigned | len | |||
) |
Set the maximum length of a received message payload.
set | The connection set to configure | |
len | The maximum payload length in bytes. Must be greater than zero. |
This is intended only as a denial-of-service prevention measure, and should be set to a value larger than any legitimate message possible in your protocol.
int mrpc_set_listen_backlog | ( | struct mrpc_conn_set * | set, | |
unsigned | backlog | |||
) |
Set the number of accepted connections that can be waiting in the kernel.
set | The connection set to configure | |
backlog | The length of the backlog queue. Must be greater than zero. |
backlog
parameter to the listen() system call. The default value is 16. The new setting will only affect future calls to mrpc_listen(); existing listening sockets will not be affected.
int mrpc_set_accept_backoff | ( | struct mrpc_conn_set * | set, | |
unsigned | ms | |||
) |
Set the number of milliseconds to back off if accept() fails.
set | The connection set to configure | |
ms | The number of milliseconds to wait. Must be greater than zero. |
int mrpc_set_keepalive_enabled | ( | struct mrpc_conn_set * | set, | |
int | enabled | |||
) |
Set whether keepalives will be enabled on new connections.
set | The connection set to configure | |
enabled | Nonzero to enable keepalive, zero to disable it |
int mrpc_set_keepalive_parameters | ( | struct mrpc_conn_set * | set, | |
unsigned | idletime, | |||
unsigned | count, | |||
unsigned | interval | |||
) |
Set TCP keepalive parameters for new connections.
set | The connection set to configure | |
idletime | The number of seconds a connection can be idle before keepalive probes are sent (default: 7200) | |
count | The number of keepalive probes to send before closing the connection (default: 9) | |
interval | The number of seconds between keepalive probe attempts (default: 75) |