_cp_socket Struct Reference

#include <socket.h>

Data Fields

int id
int port
int backlog
timeval delay
int connections_served
timeval created
int poolsize_min
int poolsize_max
unsigned int fdn
cp_socket_strategy strategy
union {
   cp_socket_thread_function   thread_fn
   cp_socket_callback   callback
int closing
void * owner
cp_vector * shutdown_callback

Detailed Description

cp_socket is a 'server socket'. create a cp_socket to listen on a port, specify a callback to implemet your communication protocol (libcprops provides a basic http implementation you could plug in) and the strategy you want for handling handling multiple connections - use a thread pool to serve each connection on its own thread or a more select()-like approach.

If you create a socket with the CPSOCKET_STRATEGY_THREADPOOL, supply a thread function to handle communication once a connection has been accept()-ed. Your cp_thread function should close the connection when done and check the 'closing' flag, which is set to 1 on shutdown.

If you create a socket with the CPSOCKET_STRATEGY_CALLBACK, supply a callback to process incremental feeds as they come along.

Definition at line 119 of file socket.h.

Field Documentation

union { ... } _cp_socket::action

placeholder for action

int _cp_socket::backlog

max backlog

Definition at line 123 of file socket.h.

int _cp_socket::closing

shutdown flag

Definition at line 148 of file socket.h.

int _cp_socket::connections_served

number of connections accepted

Definition at line 125 of file socket.h.

struct timeval _cp_socket::created

creation time

Definition at line 126 of file socket.h.

struct timeval _cp_socket::delay

max blocking time

Definition at line 124 of file socket.h.

unsigned int _cp_socket::fdn

largest fd - needed for select()

Definition at line 138 of file socket.h.

cp_hashlist* _cp_socket::fds

all available file descriptors

Definition at line 134 of file socket.h.

int _cp_socket::id

socket id

Definition at line 121 of file socket.h.

int _cp_socket::poolsize_max

max cp_thread count for cp_thread pool

Definition at line 137 of file socket.h.

int _cp_socket::poolsize_min

min cp_thread count for cp_thread pool

Definition at line 136 of file socket.h.

int _cp_socket::port

the port this socket listens on

Definition at line 122 of file socket.h.

cp_vector* _cp_socket::shutdown_callback

shutdown callback list

Definition at line 154 of file socket.h.

cp_socket_strategy _cp_socket::strategy

threadpool or callback

Definition at line 139 of file socket.h.

cp_thread_pool* _cp_socket::tpool

cp_thread pool (if requested)

Definition at line 135 of file socket.h.

The documentation for this struct was generated from the following file:
Generated on Mon Dec 5 23:00:23 2011 for cprops by  doxygen 1.4.7