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

#include <inspsocket.h>

Inheritance diagram for StreamSocket:
EventHandler classbase BufferedSocket UserIOHandler ThreadSignalSocket

Classes

class  SendQueue
 

Public Member Functions

IOHookGetIOHook () const
 
void AddIOHook (IOHook *hook)
 
void DelIOHook ()
 
void DoWrite ()
 
void OnEventHandlerRead () CXX11_OVERRIDE
 
void OnEventHandlerWrite () CXX11_OVERRIDE
 
void OnEventHandlerError (int errcode) CXX11_OVERRIDE
 
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
 
SendQueueGetSendQ ()
 
virtual void Close ()
 
virtual CullResult cull () CXX11_OVERRIDE
 
IOHookGetModHook (Module *mod) const
 
- 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 ( )
virtual

Close the socket, remove from socket engine, etc

◆ cull()

CullResult StreamSocket::cull ( )
virtual

This ensures that close is called prior to destructor

Reimplemented from classbase.

◆ DoWrite()

void StreamSocket::DoWrite ( )

Flush the send queue

◆ getError()

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

Gets the error message for this socket.

◆ GetModHook()

IOHook * StreamSocket::GetModHook ( Module mod) const

Get the IOHook of a module attached to this socket

Parameters
modModule whose IOHook to return
Returns
IOHook belonging to the module or NULL if the module haven't attached an IOHook to this socket

◆ GetNextLine()

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

Convenience function: read a line from the socket

Parameters
lineThe line read
delimThe line delimiter
Returns
true if a line was read

◆ getSendQSize()

size_t StreamSocket::getSendQSize ( ) const

Useful for implementing sendq exceeded

◆ OnDataReady()

virtual void StreamSocket::OnDataReady ( )
pure virtual

Called when new data is present in recvq

Implemented in UserIOHandler, BufferedSocket, and ThreadSignalSocket.

◆ 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, and ThreadSignalSocket.

◆ OnEventHandlerError()

void StreamSocket::OnEventHandlerError ( int  errcode)
virtual

Called by the socket engine on error

Parameters
errcodeError

Reimplemented from EventHandler.

Reimplemented in ThreadSignalSocket.

◆ OnEventHandlerRead()

void StreamSocket::OnEventHandlerRead ( )
virtual

Called by the socket engine on a read event

Implements EventHandler.

Reimplemented in ThreadSignalSocket.

◆ OnEventHandlerWrite()

void StreamSocket::OnEventHandlerWrite ( )
virtual

Called by the socket engine on a write event

Reimplemented from EventHandler.

Reimplemented in BufferedSocket, and ThreadSignalSocket.

◆ SetError()

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

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: