cp_socket

Section: cp_socket (3)
Updated: OCTOBER 2005
Index Return to Main Contents [view source]
 

NAME

cp_httpsocket - http server socket api  

SYNOPSIS

#include <cprops/http.h>

int cp_http_init();
int cp_http_stop_all();
void cp_http_shutdown();

cp_httpsocket *cp_httpsocket_create(int port,
                                     cp_http_service_callback service);

cp_httpsocket *
      cp_httpsocket_create_ssl(int port,
                               cp_http_service_callback service
                               char *certificate_file,
                               char *key_file,
                               int verification_mode);

void cp_httpsocket_delete(cp_httpsocket *sock);

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);  

SOCKET SETTINGS

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_socket *sock, int backlog);
void cp_httpsocket_set_delay(cp_socket *sock, struct timeval delay);
void cp_httpsocket_set_delay_sec(cp_socket *sock, long sec);
void cp_httpsocket_set_delay_usec(cp_socket *sock, long usec);
void cp_httpsocket_set_poolsize_min(cp_socket *sock, int min);
void cp_httpsocket_set_poolsize_max(cp_socket *sock, int max);  

DESCRIPTION

libcprops implements http server socket functionality with the cp_httpsock struct. Before using the framework call cp_http_init to initialize request parsing facilities. This should be matched by a call to cp_http_shutdown when done. These calls override cp_socket_init and cp_socket_shutdown. cp_httpsocket_stop_all could be called from a shutdown hook to close all open sockets and cause cp_httpsocket_listen to return.

To listen on a port, first instantiate a server socket by calling cp_httpsocket_create. The cp_httpsocket struct is a wrapper for a cp_socket backed by a thread pool to serve simultaneous requests. The service parameter defines the default cp_http_service(3). The action to be taken in response to a request for a given uri prefix is defined by means of a service. If no default service is set, the framework returns an error 501 (NOT IMPLEMENTED) page for unhandled uris. Otherwise services may be registered per uri with cp_httpsocket_register_service. Services may be removed by calling cp_httpsocket_unregister_service.

Call cp_httpsocket_listen to activate the socket. Services may still be registered after this call.

If libcprops was configured with --enable-ssl (default), SSL features are available on sockets created with cp_httpsocket_create_ssl, which requires the path to a certificate_file and a key_file as well. The verification_method may be one of SSL_VERIFY_NONE or SSL_VERIFY_PEER, optionally modified with SSL_VERIFY_FAIL_IF_NO_PEER_CERT and / or SSL_VERIFY_CLIENT_ONCE - see SSL_CTX_set_verify(3).

 

SEE ALSO

cp_http_service(3), cp_http_request(3), cp_http_response(3), SSL_CTX_set_verify(3)


 

Index

NAME
SYNOPSIS
SOCKET SETTINGS
DESCRIPTION
SEE ALSO

This document was created by man2html, using the manual pages.
Time: 21:26:15 GMT, January 30, 2006
SourceForge.net Logo