Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals

Cp_socket


Files

file  client.h
file  http.c
file  http.h
file  httpclient.h
file  socket.c
file  socket.h

Data Structures

struct  _cp_client
struct  cp_http_status_code_entry
struct  _cp_http_request
struct  _cp_http_response
struct  _cp_httpsocket
struct  _cp_http_service
struct  _cp_httpclient
struct  _cp_url_descriptor
struct  _cp_httpclient_result
struct  _cp_httpclient_ctl
struct  _cp_http_transfer_descriptor
struct  _cp_socket
struct  _cp_connection_descriptor

Defines

#define DEFAULT_CLIENT_TIMEOUT   300
#define DEFAULT_RETRIES   3
#define HTTP_PARSE_BUFSIZE   0xFFFF
#define MATCHMAX   10
#define HTTP_RE_MATCHMAX   10
#define REQUEST_STAGE_START   0
#define REQUEST_STAGE_STATUS_LINE   1
#define REQUEST_STAGE_HEADERS   2
#define REQUEST_STAGE_BODY   3
#define REQUEST_STAGE_DONE   4
#define HEXDIGIT(c)
#define DEFAULT_SERVER_NAME   "libcprops-0.1.7"
#define DEFAULT_KEEPALIVE   300
#define HTTP_KEEPALIVE   DEFAULT_KEEPALIVE
#define MAX_URL_LENGTH   0x400
#define DEFAULT_MAX_REDIRECTS   10
#define CPSOCKET_DEFAULT_BACKLOG   50
#define CPSOCKET_DEFAULT_DELAY_SEC   1
#define CPSOCKET_DEFAULT_DELAY_USEC   0
#define CPSOCKET_THREADPOOL_DEFAULT_SIZE_MIN   5
#define CPSOCKET_THREADPOOL_DEFAULT_SIZE_MAX   50
#define cp_connection_descriptor_get_socket(cd)   ((cd)->sock)
#define cp_connection_descriptor_get_addr(cd)   ((cd)->addr)
#define cp_connection_descriptor_get_fd(cd)   ((cd)->fd)

Typedefs

typedef CPROPS_DLL struct
_cp_client 
cp_client
typedef CPROPS_DLL enum { ... }  cp_http_version
typedef CPROPS_DLL enum { ... }  cp_http_status_code
typedef CPROPS_DLL enum { ... }  connection_policy
typedef CPROPS_DLL enum { ... }  cp_http_content_type
typedef CPROPS_DLL struct
_cp_http_request 
cp_http_request
typedef CPROPS_DLL struct
_cp_http_response 
cp_http_response
typedef int(* cp_http_service_callback )(cp_http_request *request, cp_http_response *response)
typedef CPROPS_DLL struct
_cp_httpsocket 
cp_httpsocket
typedef CPROPS_DLL struct
_cp_http_service 
cp_http_service
typedef CPROPS_DLL struct
_cp_httpclient 
cp_httpclient
typedef CPROPS_DLL struct
_cp_url_descriptor 
cp_url_descriptor
typedef CPROPS_DLL struct
_cp_httpclient_result 
cp_httpclient_result
typedef CPROPS_DLL struct
_cp_httpclient_ctl 
cp_httpclient_ctl
typedef void(* cp_httpclient_callback )(cp_httpclient_result *response)
typedef CPROPS_DLL struct
_cp_http_transfer_descriptor 
cp_http_transfer_descriptor
typedef CPROPS_DLL enum { ... }  cp_socket_strategy
typedef void *(* cp_socket_thread_function )(void *)
typedef int(* cp_socket_callback )(struct _cp_socket *, int fd)
typedef CPROPS_DLL struct
_cp_socket 
cp_socket
typedef CPROPS_DLL struct
_cp_connection_descriptor 
cp_connection_descriptor

Enumerations

enum  {
  OPTIONS, GET, HEAD, POST,
  PUT, DELETE, TRACE, CONNECT
}
enum  { HTTP_1_0, HTTP_1_1 }
enum  {
  HTTP_NULL_STATUS = -1, HTTP_100_CONTINUE = 100, HTTP_101_SWITCHING_PROTOCOLS = 101, HTTP_200_OK = 200,
  HTTP_201_CREATED = 201, HTTP_202_ACCEPTED = 202, HTTP_203_NON_AUTHORITATIVE_INFORMATION = 203, HTTP_204_NO_CONTENT = 204,
  HTTP_205_RESET_CONTENT = 205, HTTP_206_PARTIAL_CONTENT = 206, HTTP_300_MULTIPLE_CHOICES = 300, HTTP_301_MOVED_PERMANENTLY = 301,
  HTTP_302_FOUND = 302, HTTP_303_SEE_OTHER = 303, HTTP_304_NOT_MODIFIED = 304, HTTP_305_USE_PROXY = 305,
  HTTP_307_TEMPORARY_REDIRECT = 307, HTTP_400_BAD_REQUEST = 400, HTTP_401_UNAUTHORIZED = 401, HTTP_402_PAYMENT_REQUIRED = 402,
  HTTP_403_FORBIDDEN = 403, HTTP_404_NOT_FOUND = 404, HTTP_405_METHOD_NOT_ALLOWED = 405, HTTP_406_NOT_ACCEPTABLE = 406,
  HTTP_407_PROXY_AUTHENTICATION_REQUIRED = 407, HTTP_408_REQUEST_TIME_OUT = 408, HTTP_409_CONFLICT = 409, HTTP_410_GONE = 410,
  HTTP_411_LENGTH_REQUIRED = 411, HTTP_412_PRECONDITION_FAILED = 412, HTTP_413_REQUEST_ENTITY_TOO_LARGE = 413, HTTP_414_REQUEST_URI_TOO_LARGE = 414,
  HTTP_415_UNSUPPORTED_MEDIA_TYPE = 415, HTTP_416_REQUESTED_RANGE_NOT_SATISFIABLE = 416, HTTP_417_EXPECTATION_FAILED = 417, HTTP_500_INTERNAL_SERVER_ERROR = 500,
  HTTP_501_NOT_IMPLEMENTED = 501, HTTP_502_BAD_GATEWAY = 502, HTTP_503_SERVICE_UNAVAILABLE = 503, HTTP_504_GATEWAY_TIME_OUT = 504,
  HTTP_505_HTTP_VERSION_NOT_SUPPORTED = 505
}
enum  { HTTP_CONNECTION_POLICY_DEFAULT, HTTP_CONNECTION_POLICY_CLOSE, HTTP_CONNECTION_POLICY_KEEP_ALIVE }
enum  { TEXT, HTML, JPEG }
enum  cp_http_result_status {
  CP_HTTP_RESULT_SUCCESS, CP_HTTP_RESULT_CONNECTION_FAILED, CP_HTTP_RESULT_CONNECTION_RESET, CP_HTTP_RESULT_TIMED_OUT,
  CP_HTTP_RESULT_WRITE_ERROR, CP_HTTP_RESULT_READ_ERROR
}
enum  { CPSOCKET_STRATEGY_CALLBACK, CPSOCKET_STRATEGY_THREADPOOL }

Functions

CPROPS_DLL void cp_client_init ()
CPROPS_DLL void cp_client_stop_all ()
CPROPS_DLL void cp_client_shutdown ()
CPROPS_DLL void cp_tcp_add_shutdown_callback (void(*cb)(void *), void *prm)
CPROPS_DLL cp_clientcp_client_create (char *host, int port)
CPROPS_DLL cp_clientcp_client_create_addr (struct sockaddr_in *)
CPROPS_DLL void cp_client_set_timeout (cp_client *client, int sec, int usec)
CPROPS_DLL void cp_client_set_retry (cp_client *client, int retry_count)
CPROPS_DLL void cp_client_set_owner (cp_client *client, void *owner)
CPROPS_DLL int cp_client_connect (cp_client *client)
CPROPS_DLL int cp_client_reopen (cp_client *client, char *host, int port)
CPROPS_DLL int cp_client_close (cp_client *client)
CPROPS_DLL void cp_client_destroy (cp_client *client)
CPROPS_DLL int cp_client_read (cp_client *client, char *buf, int len)
CPROPS_DLL int cp_client_read_string (cp_client *client, cp_string *str, int len)
CPROPS_DLL int cp_client_write (cp_client *client, char *buf, int len)
CPROPS_DLL int cp_client_write_string (cp_client *client, cp_string *str)
void cp_http_signal_handler (int sig)
void * session_cleanup_thread (void *)
int cp_http_init ()
void cp_httpsocket_stop_all ()
void cp_httpsocket_stop (cp_httpsocket *sock)
void * cp_http_add_shutdown_callback (void(*cb)(void *), void *prm)
void cp_http_shutdown ()
void cp_http_request_delete (cp_http_request *request)
char * get_http_request_type_lit (cp_http_request_type type)
void urldecode (char *str, char **decoded)
char * cp_http_request_get_header (cp_http_request *req, char *header)
char ** cp_http_request_get_headers (cp_http_request *request)
char * cp_http_request_get_parameter (cp_http_request *request, char *name)
void cp_http_request_dump (cp_http_request *req)
cp_http_responsecp_http_response_create (cp_http_request *req)
void cp_http_response_delete (cp_http_response *response)
void cp_http_response_destroy (cp_http_response *res)
int cp_http_response_write (cp_connection_descriptor *cdesc, cp_http_response *res)
void cp_http_response_set_status (cp_http_response *response, cp_http_status_code status)
cp_http_status_code cp_http_response_get_status (cp_http_response *response)
void cp_http_response_set_content_type (cp_http_response *response, cp_http_content_type type)
void cp_http_response_set_content_type_string (cp_http_response *response, char *content_type)
char * cp_http_response_get_content_type (cp_http_response *response)
void cp_http_response_set_header (cp_http_response *response, char *name, char *value)
char * cp_http_response_get_header (cp_http_response *response, char *name)
cp_vector * cp_http_response_get_header_names (cp_http_response *response)
void cp_http_response_set_body (cp_http_response *response, char *body)
void cp_http_response_set_content (cp_http_response *response, cp_string *content)
cp_stringcp_http_response_get_content (cp_http_response *response)
void cp_http_response_set_connection_policy (cp_http_response *response, connection_policy policy)
void cp_http_response_skip (cp_http_response *response)
cp_httpsocketcp_httpsocket_create (int port, cp_http_service_callback service)
void cp_httpsocket_set_keepalive (cp_httpsocket *socket, int sec)
void cp_httpsocket_set_server_name (cp_httpsocket *socket, char *name)
void cp_httpsocket_set_backlog (cp_httpsocket *socket, int backlog)
void cp_httpsocket_set_delay (cp_httpsocket *socket, struct timeval delay)
void cp_httpsocket_set_delay_sec (cp_httpsocket *socket, long sec)
void cp_httpsocket_set_delay_usec (cp_httpsocket *socket, long usec)
void cp_httpsocket_set_poolsize_min (cp_httpsocket *socket, int min)
void cp_httpsocket_set_poolsize_max (cp_httpsocket *socket, int max)
void cp_httpsocket_delete (cp_httpsocket *sock)
void * cp_httpsocket_add_shutdown_callback (cp_httpsocket *socket, void(*cb)(void *), void *prm)
int cp_httpsocket_listen (cp_httpsocket *sock)
int cp_httpsocket_register_service (cp_httpsocket *server, cp_http_service *service)
void * cp_httpsocket_unregister_service (cp_httpsocket *server, cp_http_service *service)
cp_http_servicecp_http_service_create (char *name, char *path, cp_http_service_callback callback)
void cp_http_service_delete (cp_http_service *service)
void cp_http_response_report_error (cp_http_response *response, cp_http_status_code code, char *message)
void * cp_http_thread_fn (void *prm)
CPROPS_DLL cp_http_requestcp_http_request_parse (struct _cp_httpsocket *owner, char *request, int *err)
CPROPS_DLL cp_vector * cp_http_request_get_param_vector (cp_http_request *request, char *name)
CPROPS_DLL cp_vector * cp_http_request_get_params (cp_http_request *request)
__BEGIN_DECLS CPROPS_DLL int cp_httpclient_init ()
CPROPS_DLL int cp_httpclient_shutdown ()
CPROPS_DLL cp_httpclientcp_httpclient_create (char *host, int port)
CPROPS_DLL cp_httpclientcp_httpclient_create_proxy (char *host, int port, char *proxy_host, int proxy_port)
CPROPS_DLL void cp_httpclient_destroy (cp_httpclient *client)
CPROPS_DLL void cp_httpclient_set_http_version (cp_httpclient *client, cp_http_version version)
CPROPS_DLL void cp_httpclient_set_request_type (cp_httpclient *client, cp_http_request_type type)
CPROPS_DLL void cp_httpclient_set_header (cp_httpclient *client, char *header, char *value)
CPROPS_DLL void cp_httpclient_set_auto_drop_headers (cp_httpclient *client, short mode)
CPROPS_DLL void cp_httpclient_drop_headers (cp_httpclient *client)
CPROPS_DLL void * cp_httpclient_set_parameter (cp_httpclient *client, char *name, char *value)
CPROPS_DLL void cp_httpclient_set_auto_drop_parameters (cp_httpclient *client, short mode)
CPROPS_DLL void cp_httpclient_drop_parameters (cp_httpclient *client)
CPROPS_DLL void cp_httpclient_set_user_agent (cp_httpclient *client, char *agent)
CPROPS_DLL void cp_httpclient_set_timeout (cp_httpclient *client, int sec, int usec)
CPROPS_DLL void cp_httpclient_set_retry (cp_httpclient *client, int retry_count)
CPROPS_DLL void cp_httpclient_allow_redirects (cp_httpclient *client, int mode)
CPROPS_DLL void cp_httpclient_set_max_redirects (cp_httpclient *client, int max)
CPROPS_DLL int cp_httpclient_reopen (cp_httpclient *client, char *host, int port)
CPROPS_DLL cp_url_descriptorcp_url_descriptor_create (char *host, short ssl, int port, char *uri)
CPROPS_DLL void cp_url_descriptor_destroy (cp_url_descriptor *desc)
CPROPS_DLL short cp_url_descriptor_ssl (cp_url_descriptor *desc)
CPROPS_DLL char * cp_url_descriptor_host (cp_url_descriptor *desc)
CPROPS_DLL int cp_url_descriptor_port (cp_url_descriptor *desc)
CPROPS_DLL char * cp_url_descriptor_uri (cp_url_descriptor *desc)
CPROPS_DLL cp_url_descriptorcp_url_descriptor_parse (char *url)
CPROPS_DLL cp_httpclient_resultcp_httpclient_result_create (cp_httpclient *client)
CPROPS_DLL void cp_httpclient_result_destroy (cp_httpclient_result *res)
CPROPS_DLL void * cp_httpclient_result_id (cp_httpclient_result *res)
CPROPS_DLL cp_http_result_status cp_httpclient_result_status (cp_httpclient_result *res)
CPROPS_DLL cp_http_responsecp_httpclient_result_get_response (cp_httpclient_result *res)
CPROPS_DLL cp_httpclientcp_httpclient_result_get_client (cp_httpclient_result *res)
CPROPS_DLL cp_httpclient_resultcp_httpclient_fetch (cp_httpclient *client, char *uri)
CPROPS_DLL cp_httpclient_ctlcp_httpclient_ctl_create (int background)
CPROPS_DLL void cp_httpclient_ctl_destroy (cp_httpclient_ctl *ctl)
CPROPS_DLL fd_set * cp_httpclient_ctl_default_get_read_fd_set (int *num)
CPROPS_DLL fd_set * cp_httpclient_ctl_get_read_fd_set (cp_httpclient_ctl *ctl, int *num)
CPROPS_DLL fd_set * cp_httpclient_ctl_default_get_write_fd_set (int *num)
CPROPS_DLL fd_set * cp_httpclient_ctl_get_write_fd_set (cp_httpclient_ctl *ctl, int *num)
CPROPS_DLL cp_http_transfer_descriptorcp_http_transfer_descriptor_create (void *id, cp_httpclient *client, cp_httpclient_callback callback, char *uri)
CPROPS_DLL void cp_http_transfer_descriptor_destroy (cp_http_transfer_descriptor *desc)
CPROPS_DLL int cp_httpclient_fetch_nb (cp_httpclient *client, char *uri, void *id, cp_httpclient_callback callback, int background)
CPROPS_DLL int cp_httpclient_fetch_ctl (cp_httpclient_ctl *ctl, cp_httpclient *client, char *uri, void *id, cp_httpclient_callback callback)
CPROPS_DLL int cp_httpclient_fetch_nb_exec ()
CPROPS_DLL int cp_httpclient_fetch_ctl_exec (cp_httpclient_ctl *ctl)
void cp_socket_init ()
void cp_socket_stop (cp_socket *sock)
void cp_socket_stop_all ()
void cp_socket_shutdown ()
int setnonblocking (int sock)
cp_connection_descriptorcp_connection_descriptor_create (cp_socket *sock, struct sockaddr_in *addr, int fd)
void cp_connection_descriptor_destroy (cp_connection_descriptor *conn_desc)
cp_socketcp_socket_create (int port, cp_socket_strategy strategy, void *fn)
void cp_socket_set_backlog (cp_socket *socket, int backlog)
void cp_socket_set_delay (cp_socket *socket, struct timeval delay)
void cp_socket_set_delay_sec (cp_socket *socket, long sec)
void cp_socket_set_delay_usec (cp_socket *socket, long usec)
void cp_socket_set_poolsize_min (cp_socket *socket, int min)
void cp_socket_set_poolsize_max (cp_socket *socket, int max)
void cp_socket_set_owner (cp_socket *socket, void *owner)
void * cp_socket_add_shutdown_callback (cp_socket *sock, void(*cb)(void *), void *prm)
void cp_socket_delete (cp_socket *sock)
int cp_socket_listen (cp_socket *sock)
int cp_socket_select_callback_impl (cp_socket *sock)
int cp_socket_select_threadpool_impl (cp_socket *sock)
int cp_socket_select (cp_socket *sock)
int cp_socket_connection_close (cp_socket *sock, int fd)
int cp_connection_descrpitor_read (cp_connection_descriptor *desc, char *buf, int len)
int cp_connection_descriptor_write (cp_connection_descriptor *desc, char *buf, int len)

Variables

cp_http_status_code_entry cp_http_status_code_list []
volatile int cp_http_stopping = 0
__BEGIN_DECLS typedef CPROPS_DLL
enum { ... }  
cp_http_request_type
CPROPS_DLL _cp_httpsocket
volatile int stopping_all = 0

Define Documentation

#define cp_connection_descriptor_get_addr cd   )     ((cd)->addr)
 

return client address for given connection descriptor

Definition at line 254 of file socket.h.

#define cp_connection_descriptor_get_fd cd   )     ((cd)->fd)
 

return file descriptor for given connection descriptor

Definition at line 256 of file socket.h.

Referenced by cp_http_response_write().

#define cp_connection_descriptor_get_socket cd   )     ((cd)->sock)
 

return cp_socket struct for given connection descriptor

Definition at line 252 of file socket.h.

Referenced by cp_http_response_write().

#define DEFAULT_CLIENT_TIMEOUT   300
 

seconds to wait for responses

Definition at line 50 of file client.h.

#define DEFAULT_RETRIES   3
 

default connect retries

Definition at line 53 of file client.h.

#define HEXDIGIT  ) 
 

Value:

((c) >= '0' && (c) <= '9' ? (c) - '0' : \
                     ((c) >= 'A' && (c) <= 'F' ? (c) - 'A' + 0xA : \
                     ((c) >= 'a' && (c) <= 'f' ? (c) - 'a' + 0xA : -1)))

Definition at line 903 of file http.c.


Typedef Documentation

typedef { ... } connection_policy
 

connection handling policy. HTTP_CONNECTION_POLICY_DEFAULT defaults to HTTP_CONNECTION_POLICY_CLOSE for HTTP/1.0 and to HTTP_CONNECTION_POLICY_KEEP_ALIVE for HTTP/1.1.

typedef CPROPS_DLL struct _cp_client cp_client
 

cp_client is a 'client socket'. create a cp_client with address information, call cp_client_connect() and communicate on the resulting file descriptor.

Referenced by cp_client_create(), and cp_client_create_addr().

typedef CPROPS_DLL struct _cp_connection_descriptor cp_connection_descriptor
 

connection descriptor structure

Referenced by cp_connection_descriptor_create().

typedef CPROPS_DLL struct _cp_http_request cp_http_request
 

http request descriptor

typedef CPROPS_DLL struct _cp_http_response cp_http_response
 

http response holder

Referenced by cp_http_response_create(), cp_httpclient_fetch(), and cp_httpclient_result_get_response().

typedef CPROPS_DLL struct _cp_http_service cp_http_service
 

http service descriptor

Referenced by cp_http_service_create().

typedef int(* cp_http_service_callback)(cp_http_request *request, cp_http_response *response)
 

service function prototype

Definition at line 483 of file http.h.

typedef { ... } cp_http_status_code
 

HTTP status codes

Referenced by cp_http_response_get_status().

typedef CPROPS_DLL struct _cp_http_transfer_descriptor cp_http_transfer_descriptor
 

transfer descriptor for async interface

Referenced by cp_httpclient_ctl_create(), and cp_httpclient_fetch_ctl().

typedef { ... } cp_http_version
 

HTTP versions

typedef CPROPS_DLL struct _cp_httpclient cp_httpclient
 

http client socket wrapper

Referenced by cp_httpclient_create(), cp_httpclient_create_proxy(), and cp_httpclient_result_get_client().

typedef CPROPS_DLL struct _cp_httpclient_ctl cp_httpclient_ctl
 

asynchronous interface control block. By default asynchronous transfers use a static block shared between all client transfers. To separate transfers into different groups, create a cp_httpclient_ctl control block and use _fetch_ctl_nb and _fetch_ctl_nb_exec().

Referenced by cp_httpclient_ctl_create().

typedef CPROPS_DLL struct _cp_httpclient_result cp_httpclient_result
 

wrapper for asynchronous interface callback

Referenced by cp_httpclient_fetch(), and cp_httpclient_result_create().

typedef CPROPS_DLL struct _cp_httpsocket cp_httpsocket
 

http server socket

Referenced by cp_httpsocket_create().

typedef CPROPS_DLL struct _cp_socket cp_socket
 

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.

Referenced by cp_http_response_write(), cp_httpsocket_create(), cp_socket_create(), and cp_socket_stop_all().

typedef int(* cp_socket_callback)(struct _cp_socket *, int fd)
 

function prototype for callback implementation

Definition at line 98 of file socket.h.

typedef { ... } cp_socket_strategy
 

cp_socket connection handling strategy

typedef void*(* cp_socket_thread_function)(void *)
 

thread function for threadpool implementation

Definition at line 96 of file socket.h.

typedef CPROPS_DLL struct _cp_url_descriptor cp_url_descriptor
 

wrapper for url information

Referenced by cp_httpclient_fetch().


Enumeration Type Documentation

anonymous enum
 

HTTP request types

Definition at line 144 of file http.h.

anonymous enum
 

HTTP versions

Definition at line 162 of file http.h.

anonymous enum
 

HTTP status codes

Definition at line 165 of file http.h.

anonymous enum
 

connection handling policy. HTTP_CONNECTION_POLICY_DEFAULT defaults to HTTP_CONNECTION_POLICY_CLOSE for HTTP/1.0 and to HTTP_CONNECTION_POLICY_KEEP_ALIVE for HTTP/1.1.

Definition at line 215 of file http.h.

anonymous enum
 

cp_socket connection handling strategy

Definition at line 86 of file socket.h.

enum cp_http_result_status
 

result codes for HTTP requests

Definition at line 262 of file httpclient.h.

Referenced by cp_httpclient_result_status().


Function Documentation

CPROPS_DLL int cp_client_close cp_client client  ) 
 

close a client connection

Definition at line 668 of file client.c.

References cp_perror().

Referenced by cp_client_reopen(), and cp_httpclient_destroy().

CPROPS_DLL int cp_client_connect cp_client client  ) 
 

open connection

Definition at line 572 of file client.c.

References _cp_client::addr, cp_error(), _cp_client::hostspec, and _cp_client::retry.

Referenced by cp_client_reopen().

CPROPS_DLL cp_client* cp_client_create char *  host,
int  port
 

create a client socket

Definition at line 396 of file client.c.

References cp_client, cp_client_destroy(), cp_perror(), _cp_client::host, _cp_client::port, and _cp_client::retry.

Referenced by cp_httpclient_create(), and cp_httpclient_create_proxy().

CPROPS_DLL cp_client* cp_client_create_addr struct sockaddr_in *  addr  ) 
 

create a client socket with a struct sockaddr *

Definition at line 496 of file client.c.

References _cp_client::addr, cp_client, and _cp_client::retry.

CPROPS_DLL void cp_client_destroy cp_client client  ) 
 

deallocate a cp_client

Definition at line 707 of file client.c.

Referenced by cp_client_create(), and cp_httpclient_destroy().

CPROPS_DLL void cp_client_init  ) 
 

recommended to call before using tcp client socket functions

Definition at line 255 of file client.c.

References cp_fatal(), and cp_socket_init().

Referenced by cp_httpclient_init().

CPROPS_DLL int cp_client_reopen cp_client client,
char *  host,
int  port
 

use the same wrapper for a different address. this will close an existing connection, change the host and port settings on the wrapper and attempt to connect. maybe rename this function.

Definition at line 450 of file client.c.

References _cp_client::addr, cp_client_close(), cp_client_connect(), cp_error(), cp_perror(), _cp_client::host, _cp_client::hostspec, and _cp_client::port.

Referenced by cp_httpclient_fetch(), and cp_httpclient_reopen().

CPROPS_DLL void cp_client_set_owner cp_client client,
void *  owner
 

useful free pointer for client code

Definition at line 527 of file client.c.

References _cp_client::owner.

CPROPS_DLL void cp_client_set_retry cp_client client,
int  retry_count
 

number of connection retries

Definition at line 521 of file client.c.

References _cp_client::retry.

Referenced by cp_httpclient_set_retry().

CPROPS_DLL void cp_client_set_timeout cp_client client,
int  sec,
int  usec
 

set the timeout - (0, 0) for no timeout

Definition at line 514 of file client.c.

References _cp_client::timeout.

Referenced by cp_httpclient_set_timeout().

CPROPS_DLL void cp_client_shutdown  ) 
 

performs cleanup

Definition at line 271 of file client.c.

References cp_socket_shutdown().

Referenced by cp_httpclient_shutdown().

CPROPS_DLL void cp_client_stop_all  ) 
 

call from signal handler to stop sockets in waiting select() and close all connections

CPROPS_DLL cp_connection_descriptor * cp_connection_descriptor_create cp_socket sock,
struct sockaddr_in *  addr,
int  fd
 

internal: create a new connection descriptor

Definition at line 391 of file socket.c.

References _cp_connection_descriptor::addr, cp_connection_descriptor, cp_error(), and _cp_connection_descriptor::sock.

CPROPS_DLL void cp_connection_descriptor_destroy cp_connection_descriptor conn_desc  ) 
 

deallocate a connection descriptor

Definition at line 428 of file socket.c.

References cp_socket_connection_close().

CPROPS_DLL int cp_connection_descriptor_write cp_connection_descriptor desc,
char *  buf,
int  len
 

write on a connection descriptor

Definition at line 1118 of file socket.c.

References _cp_connection_descriptor::bytes_sent, and cp_error().

CPROPS_DLL int cp_connection_descrpitor_read cp_connection_descriptor desc,
char *  buf,
int  len
 

read from a connection descriptor

Definition at line 1093 of file socket.c.

References _cp_connection_descriptor::bytes_read, and cp_error().

CPROPS_DLL void * cp_http_add_shutdown_callback void(*)(void *)  cb,
void *  prm
 

called when shutting down http layer

Definition at line 278 of file http.c.

References cp_wrap.

CPROPS_DLL int cp_http_init  ) 
 

recommended to call before using cp_httpsocket api

Definition at line 198 of file http.c.

References COLLECTION_MODE_DEEP, cp_hash_compare_int(), cp_hash_int(), cp_hashlist_create_by_mode(), cp_hashtable_create(), cp_hashtable_put(), and cp_socket_init().

Referenced by cp_httpsocket_create().

CPROPS_DLL void cp_http_request_delete cp_http_request request  ) 
 

deallocate an http request descriptor

Definition at line 679 of file http.c.

References cp_hashtable_destroy().

CPROPS_DLL void cp_http_request_dump cp_http_request req  ) 
 

dump a cp_http_request descriptor (uses cp_info)

Definition at line 1017 of file http.c.

References cp_hashtable_count(), cp_hashtable_get(), and cp_hashtable_get_keys().

CPROPS_DLL char * cp_http_request_get_header cp_http_request request,
char *  name
 

return value of specified header or NULL if none

Definition at line 977 of file http.c.

References cp_hashtable_get().

CPROPS_DLL char ** cp_http_request_get_headers cp_http_request request  ) 
 

return a newly allocated array of header names

Definition at line 987 of file http.c.

References cp_hashtable_get_keys().

CPROPS_DLL cp_vector* cp_http_request_get_param_vector cp_http_request request,
char *  name
 

return vector of GET or POST parameters with specified name

CPROPS_DLL char * cp_http_request_get_parameter cp_http_request request,
char *  name
 

return a single parameter with the specified name

Definition at line 996 of file http.c.

References cp_hashtable_get().

CPROPS_DLL cp_vector* cp_http_request_get_params cp_http_request request  ) 
 

return all GET or POST parameters for given request

CPROPS_DLL cp_http_request* cp_http_request_parse struct _cp_httpsocket owner,
char *  request,
int *  err
 

parse an http request

CPROPS_DLL cp_http_response * cp_http_response_create cp_http_request request  ) 
 

(internal) create a new response descriptor

Definition at line 1082 of file http.c.

References COLLECTION_MODE_COPY, COLLECTION_MODE_DEEP, COLLECTION_MODE_NOSYNC, cp_copy_fn, cp_hash_compare_string(), cp_hash_string(), cp_hashtable_create_by_option(), cp_http_response, _cp_http_response::header, _cp_http_response::request, _cp_http_response::servername, _cp_http_response::status, and _cp_http_response::version.