18 #ifndef LIBCOUCHBASE_COUCHBASE_H
19 #error "include libcouchbase/couchbase.h first"
83 #define LCB_IOV_LAYOUT_UIO
84 typedef struct lcb_iovec_st {
90 #define LCB_IOV_LAYOUT_WSABUF
91 typedef struct lcb_iovec_st {
100 struct sockaddr *name;
105 struct sockaddr *name;
120 typedef struct lcb_io_opt_st* lcb_io_opt_t;
132 (lcb_socket_t sock,
short events,
void *uarg);
144 typedef void *(*lcb_io_timer_create_fn)
156 (lcb_io_opt_t iops,
void *timer);
169 (lcb_io_opt_t iops,
void *timer);
182 (lcb_io_opt_t iops,
void *timer,
202 typedef void *(*lcb_ioE_event_create_fn)
213 (lcb_io_opt_t iops,
void *event);
227 (lcb_io_opt_t iops, lcb_socket_t sock,
void *event);
231 #define LCB_READ_EVENT 0x02
233 #define LCB_WRITE_EVENT 0x04
235 #define LCB_ERROR_EVENT 0x08
236 #define LCB_RW_EVENT (LCB_READ_EVENT|LCB_WRITE_EVENT)
281 (lcb_io_opt_t iops, lcb_socket_t sock,
void *target_buf,
282 lcb_SIZE buflen,
int _unused_flags);
288 (lcb_io_opt_t iops, lcb_socket_t sock,
const void *srcbuf,
289 lcb_SIZE buflen,
int _ignored);
294 (lcb_io_opt_t iops, lcb_socket_t sock,
lcb_IOV *iov, lcb_SIZE niov);
299 (lcb_io_opt_t iops, lcb_socket_t sock,
lcb_IOV *iov, lcb_SIZE niov);
304 (lcb_io_opt_t iops,
int domain,
int type,
int protocol);
311 const struct sockaddr *dst,
312 unsigned int addrlen);
315 typedef int (*lcb_ioE_bind_fn)
318 const struct sockaddr *srcaddr,
319 unsigned int addrlen);
322 typedef int (*lcb_ioE_listen_fn)
324 lcb_socket_t bound_sock,
325 unsigned int queuelen);
330 lcb_socket_t lsnsock);
335 (lcb_io_opt_t iops, lcb_socket_t sock);
348 #define LCB_IO_SOCKCHECK_PEND_IS_ERROR 1
350 #define LCB_IO_SOCKCHECK_STATUS_CLOSED 1
351 #define LCB_IO_SOCKCHECK_STATUS_OK 0
352 #define LCB_IO_SOCKCHECK_STATUS_UNKNOWN -1
370 (lcb_io_opt_t iops, lcb_socket_t sock,
int flags);
375 struct ringbuffer_st;
376 struct lcb_connection_st;
383 struct ringbuffer_st *ringbuffer;
384 struct lcb_iovec_st iov[2];
393 typedef struct lcb_sockdata_st {
403 typedef struct lcb_io_writebuf_st {
404 struct lcb_io_opt_st *parent;
422 (lcb_io_opt_t iops,
int domain,
int type,
int protocol);
443 const struct sockaddr *dst,
469 const struct sockaddr *listen_addr,
485 #define lcb_io_read_cb lcb_ioC_read_callback
494 #define lcb_io_write_cb lcb_ioC_write_callback
545 (lcb_sockdata_t *sd, lcb_SSIZE nread,
void *arg);
597 (lcb_io_opt_t iops, lcb_sockdata_t *sd,
int flags);
620 LCB_DEPRECATED(
typedef void (*lcb_io_error_cb)(lcb_sockdata_t *socket));
622 #define LCB_IOPS_BASE_FIELDS \
710 void (*
send_error)(
struct lcb_io_opt_st*, lcb_sockdata_t*,void(*)(lcb_sockdata_t*));
717 typedef struct lcb_timerprocs_st {
725 typedef struct lcb_loopprocs_st {
731 typedef struct lcb_bsdprocs_st {
739 lcb_ioE_bind_fn bind;
740 lcb_ioE_listen_fn listen;
741 lcb_ioE_accept_fn accept;
746 typedef struct lcb_evprocs_st {
870 struct lcb_iops2_st {
873 struct lcbio_TABLE *iot;
881 #define LCB_IOPROCS_VERSION 3
883 struct lcb_io_opt_st {
886 void (*destructor)(
struct lcb_io_opt_st *iops);
895 struct lcb_iops2_st v2;
908 (
int version, lcb_io_opt_t *io,
void *cookie);
int(* lcb_ioC_chkclosed_fn)(lcb_io_opt_t iops, lcb_sockdata_t *sd, int flags)
This is the completion variant of lcb_ioE_chkclosed_fn.
Definition: iops.h:597
lcb_error_t(* lcb_io_create_fn)(int version, lcb_io_opt_t *io, void *cookie)
Signature for a loadable plugin's IOPS initializer.
Definition: iops.h:908
lcb_io_stop_fn stop_event_loop
Start the event loop.
Definition: iops.h:648
lcb_ioE_event_watch_fn update_event
Watch a socket for events.
Definition: iops.h:645
IOPS optimized for IOCP-style IO.
Definition: iops.h:688
lcb_ioE_event_create_fn create_event
Create a socket event handle.
Definition: iops.h:643
struct lcbio_SOCKET * lcbconn
Internal socket equivalent.
Definition: iops.h:396
void(* lcb_io_procs_fn)(int version, lcb_loop_procs *loop_procs, lcb_timer_procs *timer_procs, lcb_bsd_procs *bsd_procs, lcb_ev_procs *ev_procs, lcb_completion_procs *completion_procs, lcb_iomodel_t *iomodel)
Definition: iops.h:861
void(* lcb_io_timer_cancel_fn)(lcb_io_opt_t iops, void *timer)
Cancel a pending timer callback.
Definition: iops.h:169
void( lcb_ioC_serve_callback)(lcb_sockdata_t *sd_server, lcb_sockdata_t *sd_client, int status)
Callback invoked when a new client connection has been established.
Definition: iops.h:454
lcb_ioE_send_fn send
Send data from a single buffer.
Definition: iops.h:633
void(* lcb_ioE_event_cancel_fn)(lcb_io_opt_t iops, lcb_socket_t sock, void *event)
Cancel pending callbacks and unwatch a handle.
Definition: iops.h:227
lcb_socket_t(* lcb_ioE_socket_fn)(lcb_io_opt_t iops, int domain, int type, int protocol)
Create a new socket.
Definition: iops.h:304
int(* lcb_io_timer_schedule_fn)(lcb_io_opt_t iops, void *timer, lcb_U32 usecs, void *uarg, lcb_ioE_callback callback)
Schedule a callback to be invoked within a given interval.
Definition: iops.h:182
Socket handle for completion-based I/O.
Definition: iops.h:393
structure indicating a buffer and its size
Definition: iops.h:84
IOPS For poll-style notification.
Definition: iops.h:628
structure describing a connected socket's endpoints
Definition: iops.h:98
void(* lcb_ioE_close_fn)(lcb_io_opt_t iops, lcb_socket_t sock)
Close a socket.
Definition: iops.h:335
void(* lcb_io_timer_destroy_fn)(lcb_io_opt_t iops, void *timer)
Destroy a timer handler.
Definition: iops.h:156
void(* lcb_ioC_write_callback)(lcb_sockdata_t *, lcb_io_writebuf_t *, int)
Definition: iops.h:493
lcb_io_start_fn run_event_loop
Stop the event loop.
Definition: iops.h:649
int(* lcb_ioC_write2_fn)(lcb_io_opt_t iops, lcb_sockdata_t *sd, lcb_IOV *iov, lcb_SIZE niov, void *uarg, lcb_ioC_write2_callback callback)
Schedule a flush of a series of buffers to the network.
Definition: iops.h:530
void *(* lcb_ioE_event_create_fn)(lcb_io_opt_t iops)
Create a new event handle.
Definition: iops.h:203
lcb_io_timer_create_fn create_timer
Create a new timer handle.
Definition: iops.h:638
void(* lcb_io_stop_fn)(lcb_io_opt_t iops)
Pause the event loop.
Definition: iops.h:618
int(* lcb_ioC_read_fn)(lcb_io_opt_t, lcb_sockdata_t *, lcb_ioC_read_callback)
Definition: iops.h:487
void(* lcb_io_start_fn)(lcb_io_opt_t iops)
Start the event loop.
Definition: iops.h:609
lcb_ioE_recv_fn recv
Receive data into a single buffer.
Definition: iops.h:632
void *(* lcb_io_timer_create_fn)(lcb_io_opt_t iops)
Create a new timer object.
Definition: iops.h:145
lcb_io_writebuf_t *(* lcb_ioC_wballoc_fn)(lcb_io_opt_t, lcb_sockdata_t *)
Definition: iops.h:489
lcb_SSIZE(* lcb_ioE_sendv_fn)(lcb_io_opt_t iops, lcb_socket_t sock, lcb_IOV *iov, lcb_SIZE niov)
Write data from multiple buffers.
Definition: iops.h:299
int(* lcb_ioC_serve_fn)(lcb_io_opt_t iops, lcb_sockdata_t *server_socket, const struct sockaddr *listen_addr, lcb_ioC_serve_callback callback)
Specify that the socket start accepting connections.
Definition: iops.h:467
lcb_io_opt_t parent
Parent I/O context.
Definition: iops.h:395
int(* lcb_ioE_event_watch_fn)(lcb_io_opt_t iops, lcb_socket_t socket, void *event, short evflags, void *uarg, lcb_ioE_callback callback)
Associate an event with a socket, requesting notification when one of the events specified in 'flags'...
Definition: iops.h:264
LCB_IOPS_BASE_FIELDS lcb_ioE_socket_fn socket
Create a socket.
Definition: iops.h:630
void(* lcb_ioE_callback)(lcb_socket_t sock, short events, void *uarg)
Callback invoked for all poll-like events.
Definition: iops.h:132
Common functions for starting and stopping the event loop.
Definition: iops.h:725
unsigned int(* lcb_ioC_close_fn)(lcb_io_opt_t iops, lcb_sockdata_t *sd)
Asynchronously shutdown the socket.
Definition: iops.h:584
lcb_io_timer_schedule_fn update_timer
Schedule a timer.
Definition: iops.h:641
int(* lcb_ioC_write_fn)(lcb_io_opt_t, lcb_sockdata_t *, lcb_io_writebuf_t *, lcb_ioC_write_callback)
Definition: iops.h:498
int(* lcb_ioC_nameinfo_fn)(lcb_io_opt_t iops, lcb_sockdata_t *sock, struct lcb_nameinfo_st *ni)
Request address information on a connected socket.
Definition: iops.h:479
void(* lcb_ioC_read2_callback)(lcb_sockdata_t *sd, lcb_SSIZE nread, void *arg)
Callback invoked when a read has been completed.
Definition: iops.h:545
lcb_sockdata_t *(* lcb_ioC_socket_fn)(lcb_io_opt_t iops, int domain, int type, int protocol)
Create a completion socket handle.
Definition: iops.h:422
int is_reading
Internally used by lcbio.
Definition: iops.h:398
lcb_SSIZE(* lcb_ioE_recvv_fn)(lcb_io_opt_t iops, lcb_socket_t sock, lcb_IOV *iov, lcb_SIZE niov)
Read data into a series of buffers.
Definition: iops.h:294
void(* lcb_ioC_write2_callback)(lcb_sockdata_t *sd, int status, void *arg)
Callback received when a buffer has been flushed.
Definition: iops.h:508
lcb_ioE_close_fn close
Close a socket.
Definition: iops.h:636
Common functions for starting and stopping timers.
Definition: iops.h:717
int(* lcb_ioC_connect_fn)(lcb_io_opt_t iops, lcb_sockdata_t *sd, const struct sockaddr *dst, unsigned int naddr, lcb_io_connect_cb callback)
Request a connection for a socket.
Definition: iops.h:442
void(* lcb_io_connect_cb)(lcb_sockdata_t *socket, int status)
Callback to be invoked upon a connection result.
Definition: iops.h:430
lcb_io_timer_cancel_fn delete_timer
Cancel a pending timer.
Definition: iops.h:640
int(* lcb_ioC_read2_fn)(lcb_io_opt_t iops, lcb_sockdata_t *sd, lcb_IOV *iov, lcb_SIZE niov, void *uarg, lcb_ioC_read2_callback callback)
Schedule a read from the network.
Definition: iops.h:562
int closed
Definition: iops.h:397
lcb_SSIZE(* lcb_ioE_send_fn)(lcb_io_opt_t iops, lcb_socket_t sock, const void *srcbuf, lcb_SIZE buflen, int _ignored)
Send data from a single buffer.
Definition: iops.h:288
void(* lcb_ioC_read_callback)(lcb_sockdata_t *sd, lcb_SSIZE nread)
Definition: iops.h:484
lcb_ioE_recvv_fn recvv
Receive data into multiple buffers.
Definition: iops.h:634
Functions handling socket watcher events.
Definition: iops.h:746
lcb_socket_t socket
System socket, for informational purposes.
Definition: iops.h:394
lcb_iomodel_t
Enumeration defining the I/O model.
Definition: iops.h:772
lcb_error_t
Error codes returned by the library.
Definition: error.h:425
int(* lcb_ioE_connect_fn)(lcb_io_opt_t iops, lcb_socket_t sock, const struct sockaddr *dst, unsigned int addrlen)
Connect a created socket.
Definition: iops.h:309
lcb_SSIZE(* lcb_ioE_recv_fn)(lcb_io_opt_t iops, lcb_socket_t sock, void *target_buf, lcb_SIZE buflen, int _unused_flags)
Receive data into a single buffer.
Definition: iops.h:281
lcb_ioE_event_destroy_fn destroy_event
Destroy a socket event handle.
Definition: iops.h:644
void(* lcb_ioE_event_destroy_fn)(lcb_io_opt_t iops, void *event)
Destroy an event handle.
Definition: iops.h:213
lcb_io_timer_destroy_fn destroy_timer
Destroy a timer handle.
Definition: iops.h:639
IOCP/Completion style.
Definition: iops.h:774
int lcb_socket_t
Type representing the native socket type of the operating system.
Definition: iops.h:76
lcb_ioE_sendv_fn sendv
Send data from multiple buffers.
Definition: iops.h:635
void(* send_error)(struct lcb_io_opt_st *, lcb_sockdata_t *, void(*)(lcb_sockdata_t *))
Definition: iops.h:710
lcb_ioE_connect_fn connect
Connect a socket.
Definition: iops.h:631
Functions for completion-based I/O.
Definition: iops.h:754
void(* lcb_ioC_wbfree_fn)(lcb_io_opt_t, lcb_sockdata_t *, lcb_io_writebuf_t *)
Definition: iops.h:491
int(* lcb_ioE_chkclosed_fn)(lcb_io_opt_t iops, lcb_socket_t sock, int flags)
Check if a socket has been closed or not.
Definition: iops.h:370
Functions wrapping the Berkeley Socket API.
Definition: iops.h:731
Event/Poll style.
Definition: iops.h:773