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

NetHandler< Lock > Class Template Reference

Inherits IOHandler.

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

List of all members.


Detailed Description

template<class Lock = __nmstl_no_lock>
class NetHandler< 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

 NetHandler (IOEventLoop &loop, IOHandle ioh, bool established=false)
 NetHandler (IOEventLoop &loop)
virtual ~NetHandler ()
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>
NetHandler< Lock >::NetHandler (  IOEventLoop &    loop,
IOHandle    ioh,
bool    established = false
)  [protected]
 

template<class Lock = __nmstl_no_lock>
NetHandler< Lock >::NetHandler (  IOEventLoop &    loop )  [protected]
 

template<class Lock = __nmstl_no_lock>
virtual NetHandler< Lock >::~NetHandler (    )  [protected, virtual]
 


Member Function Documentation

template<class Lock = __nmstl_no_lock>
virtual void NetHandler< 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 NetHandler< 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 NetHandler< Lock >::get_socket (    ) 
 

Returns the Socket for this handler.

template<class Lock = __nmstl_no_lock>
virtual int NetHandler< 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 NetHandler< Lock >::is_connected (    ) 
 

Returns true if connected.

template<class Lock = __nmstl_no_lock>
void NetHandler< Lock >::set_socket (  Socket    ioh,
bool    established = false
) 
 

Sets the Socket for this handler.

template<class Lock = __nmstl_no_lock>
bool NetHandler< Lock >::write (  string    s ) 
 

Reimplemented in MsgHandler< Header, Lock >.

template<class Lock = __nmstl_no_lock>
bool NetHandler< Lock >::write (  constbuf    buf ) 
 

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

Reimplemented in MsgHandler< Header, Lock >.


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