[view source]
int cp_httpclient_reopen(cp_httpclient *client, char *host, int port);
struct pollfd *
cp_httpclient_ctl_get_pollfds(cp_httpclient_ctl *ctl, int *num);
fd_set *
cp_httpclient_ctl_get_read_fd_set(cp_httpclient_ctl *ctl, int *num);
fd_set *
cp_httpclient_ctl_get_write_fd_set(cp_httpclient_ctl *ctl, int *num);
int cp_httpclient_fetch_ctl(cp_httpclient_ctl *ctl,
cp_httpclient *client,
char *uri, void *id,
cp_httpclient_callback callback);
int cp_httpclient_fetch_ctl_exec(cp_httpclient_ctl *ctl);
Here is a description of possible scenarios for performing HTTP calls.
o create a client
o issue a call to cp_httpclient_fetch, specifying a uri. The call is
processed inline and blocks until a response is read or an error
occurs.
o once done processing the result structure, release it by calling
cp_httpclient_result_destroy()
o create a client for each distinct host : port pair
o for each client, issue a call to cp_httpclient_fetch_nb,
specifying a uri, an id and a callback, with a value of 0 for the
background parameter. The request is added to an internal control
stack.
o repeatedly call cp_httpclient_fetch_nb_exec() until it returns 0.
o you might want to call poll() to prevent spinning on the call to
cp_httpclient_fetch_nb_exec(). use
cp_httpclient_ctl_default_get_pollfds() to retrieve an array
of struct pollfd objects for the underlying file descriptors and
call poll() with a non-zero timeout.
On systems where poll (2) is unavailable, equivalent select (2) based
functions are available - see cp_httpclient_ctl (3).
o cp_httpclient_fetch_nb_exec will perform the callbacks given when
issuing the requests. Do not call cp_httpclient_result_destroy -
the cp_httpclient_result objects are released by the framework in
this case.
o create a client for each distinct host : port pair
o for each client, issue a call to cp_httpclient_fetch_nb,
specifying a uri, an id and a callback, with a value of 1 for the
background parameter. The request is added to an internal control
stack and the requests are processed in a separate thread.
Completed requests or errors will trigger the respective callbacks
with cp_httpclient_result objects describing the server response.
The result objects are released by the framework.
o create an asynchronous interface control block by calling
cp_httpclient_ctl(). The background value determines the control
block behavior as follows:
o with a background value of 0 proceed as detailed under single
thread, but use cp_httpclient_fetch_ctl(),
cp_httpclient_fetch_ctl_exec and cp_httpclient_ctl_get_pollfds()
rather than the functions for the default group transferring.
o with a non-zero background value proceed as detailed under
multi-threaded. For values of 2 or above a thread pool of the given
size will be used to perform transfers. Which could make sense on
machines with more than one cpu when the callback processing time
is comparable to the network time.
In all cases, a call to cp_httpclient_init() to initialize the api must be made before issuing requests. cp_httpclient_shutdown() must be called to perform cleanup.
for more detail see the man pages for specific functions.
|
This document was created by
man2html,
using the manual pages. Time: 23:42:32 GMT, May 09, 2006 |
|