InspIRCd  2.0
 All Classes Namespaces Functions Variables Typedefs Enumerations
Public Member Functions | Protected Attributes | List of all members
StreamSocket Class Referenceabstract

#include <inspsocket.h>

Inheritance diagram for StreamSocket:
EventHandler classbase BufferedSocket UserIOHandler ThreadSignalSocket

Public Member Functions

ModuleGetIOHook ()
void AddIOHook (Module *m)
void DelIOHook ()
virtual void HandleEvent (EventType et, int errornum=0)
virtual void DoRead ()
virtual void DoWrite ()
void SetError (const std::string &err)
const std::string & getError () const
virtual void OnDataReady ()=0
virtual void OnError (BufferedSocketError e)=0
void WriteData (const std::string &data)
bool GetNextLine (std::string &line, char delim= '\n')
size_t getSendQSize () const
virtual void Close ()
virtual CullResult cull ()
- Public Member Functions inherited from EventHandler
int GetFd () const
int GetEventMask () const
void SetFd (int FD)
 EventHandler ()
virtual ~EventHandler ()

Protected Attributes

std::string recvq
- Protected Attributes inherited from EventHandler
int fd

Detailed Description

StreamSocket is a class that wraps a TCP socket and handles send and receive queues, including passing them to IO hooks

Member Function Documentation

void StreamSocket::Close ( )

Close the socket, remove from socket engine, etc

CullResult StreamSocket::cull ( )

This ensures that close is called prior to destructor

Reimplemented from classbase.

void StreamSocket::DoRead ( )

Dispatched from HandleEvent

void StreamSocket::DoWrite ( )

Dispatched from HandleEvent

Reimplemented in BufferedSocket.

const std::string& StreamSocket::getError ( ) const

Gets the error message for this socket.

bool StreamSocket::GetNextLine ( std::string &  line,
char  delim = '\n' 

Convenience function: read a line from the socket

lineThe line read
delimThe line delimiter
true if a line was read
size_t StreamSocket::getSendQSize ( ) const

Useful for implementing sendq exceeded

void StreamSocket::HandleEvent ( EventType  et,
int  errornum = 0 

Handle event from socket engine. This will call OnDataReady if there is new data in recvq

Implements EventHandler.

Reimplemented in ThreadSignalSocket.

virtual void StreamSocket::OnDataReady ( )
pure virtual

Called when new data is present in recvq

Implemented in UserIOHandler, BufferedSocket, and ThreadSignalSocket.

virtual void StreamSocket::OnError ( BufferedSocketError  e)
pure virtual

Called when the socket gets an error from socket engine or IO hook

Implemented in UserIOHandler, and ThreadSignalSocket.

void StreamSocket::SetError ( const std::string &  err)

Sets the error message for this socket. Once set, the socket is dead.

void StreamSocket::WriteData ( const std::string &  data)

Send the given data out the socket, either now or when writes unblock

The documentation for this class was generated from the following files: