minirpc.h.in File Reference


Detailed Description

Common interface to the miniRPC library.


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.

Typedefs

typedef int mrpc_status_t
 Error code returned by protocol operations.
typedef void *( mrpc_accept_fn )(void *set_data, struct mrpc_connection *conn, struct sockaddr *from, socklen_t from_len)
 Event callback fired on arrival of a new connection.
typedef void( mrpc_disconnect_fn )(void *conn_data, enum mrpc_disc_reason reason)
 Event callback fired on connection close.
typedef void( mrpc_ioerr_fn )(void *conn_data, char *message)
 Event callback fired on I/O error.

Enumerations

enum  mrpc_status_codes {
  MINIRPC_OK = 0, MINIRPC_PENDING = -1, MINIRPC_ENCODING_ERR = -2, MINIRPC_PROCEDURE_UNAVAIL = -3,
  MINIRPC_INVALID_ARGUMENT = -4, MINIRPC_INVALID_PROTOCOL = -5, MINIRPC_NETWORK_FAILURE = -6
}
 Error codes defined by miniRPC. More...
enum  mrpc_disc_reason { MRPC_DISC_USER, MRPC_DISC_CLOSED, MRPC_DISC_IOERR }
 Reasons that a connection could have been closed. More...
enum  mrpc_conn_counter {
  MRPC_CONNCTR_SEND_BYTES, MRPC_CONNCTR_RECV_BYTES, MRPC_CONNCTR_SEND_MSGS, MRPC_CONNCTR_RECV_MSGS,
  MRPC_CONNCTR_NR
}
 Statistics counters maintained by a connection. More...

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.
int mrpc_conn_create (struct mrpc_connection **new_conn, struct mrpc_conn_set *set, void *data)
 Create a new connection handle.
void mrpc_conn_ref (struct mrpc_connection *conn)
 Increment the refcount of a connection.
void mrpc_conn_unref (struct mrpc_connection *conn)
 Decrement the refcount of a connection.
int mrpc_connect (struct mrpc_connection *conn, int family, const char *host, const char *service)
 Make a new outgoing connection.
int mrpc_listen (struct mrpc_conn_set *set, int family, const char *listenaddr, char **service)
 Start listening for incoming connections.
int mrpc_bind_fd (struct mrpc_connection *conn, int fd)
 Bind an existing file descriptor to a connection handle.
int mrpc_conn_get_counter (struct mrpc_connection *conn, enum mrpc_conn_counter counter, uint64_t *result)
 Get statistics counter value for the specified connection.
int mrpc_conn_close (struct mrpc_connection *conn)
 Close an existing connection.
void mrpc_listen_close (struct mrpc_conn_set *set)
 Close all listeners against a connection set.
int mrpc_start_dispatch_thread (struct mrpc_conn_set *set)
 Start a dispatcher thread for a connection set.
void mrpc_dispatcher_add (struct mrpc_conn_set *set)
 Notify miniRPC that the current thread will dispatch events for this connection set.
void mrpc_dispatcher_remove (struct mrpc_conn_set *set)
 Notify miniRPC that the current thread will no longer dispatch events for this connection set.
int mrpc_dispatch_loop (struct mrpc_conn_set *set)
 Dispatch events from this thread until the connection set is destroyed.
int mrpc_dispatch (struct mrpc_conn_set *set, int max)
 Dispatch events from this thread and then return.
int mrpc_get_event_fd (struct mrpc_conn_set *set)
 Obtain a file descriptor which will be readable when there are events to process.
int mrpc_stop_events (struct mrpc_connection *conn)
 Disable event processing for a connection.
int mrpc_start_events (struct mrpc_connection *conn)
 Re-enable event processing for a connection.
int mrpc_release_event (void)
 Allow the current event handler to run in parallel with other handlers for the same connection.
const char * mrpc_strerror (mrpc_status_t status)
 Return a brief description of the specified miniRPC error code.


Enumeration Type Documentation

Reasons that a connection could have been closed.

Parameters:
MRPC_DISC_USER The connection was closed with mrpc_conn_close()
MRPC_DISC_CLOSED The connection was closed by the remote end
MRPC_DISC_IOERR The connection was closed due to an I/O error


miniRPC 0.3.3
Documentation generated by Doxygen 1.5.6