QuickIO  0.2
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Typedefs | Functions
rsock.h File Reference

Provides a buffered socket that reconnects on errors. More...

#include "qev.h"

Go to the source code of this file.

Typedefs

typedef struct qev_rsock qev_rsock_t
 No need to worry, just a flesh wound.
 

Functions

qev_rsock_tqev_rsock_new (const gchar *addr, const guint16 port)
 Create a new reconnecting socket. More...
 
void qev_rsock_free (qev_rsock_t *rsock)
 Destroy the socket.
 
void qev_rsock_send (qev_rsock_t *rsock, const gchar *data, const gsize len)
 Send data over the socket. More...
 
gsize qev_rsock_recv (qev_rsock_t *rsock, gchar *buff, const gsize len)
 Receive data from the socket. More...
 

Detailed Description

Provides a buffered socket that reconnects on errors.

This is typically useful for blind-writing data to a socket where it's not mission critical that the data make it through (such as stats).

Author
Andrew Stone andre.nosp@m.w@cl.nosp@m.ovar..nosp@m.com

Function Documentation

qev_rsock_t* qev_rsock_new ( const gchar *  addr,
const guint16  port 
)

Create a new reconnecting socket.

The userspace buffer of this socket is limited by the userspace watermarks just like any other socket.

Parameters
addrThe address to connect to
portThe port to connect to
gsize qev_rsock_recv ( qev_rsock_t rsock,
gchar *  buff,
const gsize  len 
)

Receive data from the socket.

Will not block, and will only return data that is available.

Parameters
rsockThe socket to send data on
buffWhere to put read data
lenThe length of buff
Returns
The number of bytes read. 0 if none.
void qev_rsock_send ( qev_rsock_t rsock,
const gchar *  data,
const gsize  len 
)

Send data over the socket.

If data backs up into user space, it will be flushed on the next call. No background operations will take place.

Parameters
rsockThe socket to send data on
dataThe data to send
lenThe length of the data