Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

net_handler< Lock > Class Template Reference

Inherits io_handler.

Inherited by msg_handler< Header, Lock > [private].

List of all members.


Detailed Description

template<class Lock = __nmstl_no_lock>
class net_handler< Lock >

A handler which buffers incoming and outgoing data.

This is the handler which will be most commonly used to implement stream-oriented (as opposed to strictly message-oriented) services. Handlers should subclass the incoming_data(databuf) and end_data(databuf) methods to deal with input, and use the write(databuf) method to write data.


Public Methods

bool write (constbuf buf)
 Writes data out, buffering any data that cannot be written immediately.

bool write (string s)
socket get_socket ()
 Returns the socket for this handler.

void set_socket (socket ioh, bool established=false)
 Sets the socket for this handler.

bool is_connected ()
 Returns true if connected.


Protected Methods

 net_handler (io_event_loop &loop, iohandle ioh, bool established=false)
 net_handler (io_event_loop &loop)
virtual ~net_handler ()
virtual void connected (status stat)
 Invoked when the connection either succeeds or fails.

virtual int incoming_data (constbuf buf)=0
 Invoked whenever bytes are newly available on the stream.

virtual void end_data (constbuf buf)
 Invoked when the peer has closed the stream for writing.


Constructor & Destructor Documentation

template<class Lock = __nmstl_no_lock>
net_handler< Lock >::net_handler io_event_loop   loop,
iohandle    ioh,
bool    established = false
[protected]
 

template<class Lock = __nmstl_no_lock>
net_handler< Lock >::net_handler io_event_loop   loop [protected]
 

template<class Lock = __nmstl_no_lock>
virtual net_handler< Lock >::~net_handler   [protected, virtual]
 


Member Function Documentation

template<class Lock = __nmstl_no_lock>
virtual void net_handler< Lock >::connected status    stat [protected, virtual]
 

Invoked when the connection either succeeds or fails.

Parameters:
stat  a status code indicating whether the connection attempt was successful

template<class Lock = __nmstl_no_lock>
virtual void net_handler< Lock >::end_data constbuf    buf [protected, virtual]
 

Invoked when the peer has closed the stream for writing.

Parameters:
buf  all available data that has not yet been consumed.

template<class Lock = __nmstl_no_lock>
socket net_handler< Lock >::get_socket  
 

Returns the socket for this handler.

template<class Lock = __nmstl_no_lock>
virtual int net_handler< Lock >::incoming_data constbuf    buf [protected, pure virtual]
 

Invoked whenever bytes are newly available on the stream.

Parameters:
buf  all available data that has not yet been consumed.
Returns:
the number of bytes which the subclass has consumed (and should be removed from the front of the buffer).

template<class Lock = __nmstl_no_lock>
bool net_handler< Lock >::is_connected  
 

Returns true if connected.

template<class Lock = __nmstl_no_lock>
void net_handler< Lock >::set_socket socket    ioh,
bool    established = false
 

Sets the socket for this handler.

template<class Lock = __nmstl_no_lock>
bool net_handler< Lock >::write string    s
 

Reimplemented in msg_handler< Header, Lock >.

template<class Lock = __nmstl_no_lock>
bool net_handler< Lock >::write constbuf    buf
 

Writes data out, buffering any data that cannot be written immediately.

Reimplemented in msg_handler< Header, Lock >.


The documentation for this class was generated from the following file:
Generated on Fri Dec 20 13:35:10 2002 for NMSTL