InspIRCd  2.0
Public Member Functions | Protected Attributes | List of all members
StreamSocket Class Referenceabstract

#include <inspsocket.h>

Inheritance diagram for StreamSocket:
EventHandler classbase BufferedSocket UserIOHandler

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

◆ Close()

void StreamSocket::Close ( )

Close the socket, remove from socket engine, etc

◆ cull()

CullResult StreamSocket::cull ( )

This ensures that close is called prior to destructor

Reimplemented from classbase.

◆ DoRead()

void StreamSocket::DoRead ( )

Dispatched from HandleEvent

◆ DoWrite()

void StreamSocket::DoWrite ( )

Dispatched from HandleEvent

Reimplemented in BufferedSocket.

◆ getError()

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

Gets the error message for this socket.

◆ GetNextLine()

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

◆ getSendQSize()

size_t StreamSocket::getSendQSize ( ) const

Useful for implementing sendq exceeded

◆ HandleEvent()

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.

◆ OnDataReady()

virtual void StreamSocket::OnDataReady ( )
pure virtual

Called when new data is present in recvq

Implemented in BufferedSocket, and UserIOHandler.

◆ OnError()

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

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

Implemented in UserIOHandler.

◆ SetError()

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

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

◆ WriteData()

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: