Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   Related Pages   Examples  

fpoller::read_callback Class Template Reference

#include <callbacks.h>

Inheritance diagram for fpoller::read_callback::

fpoller::callback List of all members.

Public Methods

 read_callback (size_t block_size=4096)
ret_val operator() (int fd)

Detailed Description

template<class Parser, class ReadingPolicy = reader::socket_read, class KeepAlivePolicy = reader::purge, class ErrorHandlerPolicy = reader::stderr_report, class ReadCompletionPolicy = reader::termination_string, class Poller = poller>
class fpoller::read_callback< Parser, ReadingPolicy, KeepAlivePolicy, ErrorHandlerPolicy, ReadCompletionPolicy, Poller >

Generic callback which can be used to read arbitrary data from a socket.

All read_callbacks need to have a parser defined , for which there is no default. The parser must have a default constructor and define a function parse with the following declaration:
void parse (int fd, svec &incoming, int request_size);
This function should do any processing necessary, and probably, add a write callback to the poller, to provide a response. ReadingPolicy determines how file descriptor is read (as socket, as disk file, etc). ErrorHandler Policy, in a surprise, determines how errors are handled. ReadCompletionPolicy specifies how to determine when a read is complete (eof reached, magic string found, etc). Poller specifies type of poller that will be calling operator(). The default, poller, is almost always correct. File Descriptor is always closed in case of error.

Examples:

example.cc.

Definition at line 201 of file callbacks.h.


Member Function Documentation

template<class Parser, class ReadingPolicy = reader::socket_read, class KeepAlivePolicy = reader::purge, class ErrorHandlerPolicy = reader::stderr_report, class ReadCompletionPolicy = reader::termination_string, class Poller = poller>
ret_val fpoller::read_callback< Parser, ReadingPolicy, KeepAlivePolicy, ErrorHandlerPolicy, ReadCompletionPolicy, Poller >::operator() int fd [inline, virtual]
 

Descendant classes must implement. The parameter is the descriptor for which the callback is being called.

Reimplemented from fpoller::callback.

Definition at line 209 of file callbacks.h.


The documentation for this class was generated from the following file:
Generated at Wed Oct 16 16:02:39 2002 for fpoller by doxygen1.2.9.1 written by Dimitri van Heesch, © 1997-2001