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

#include <inspsocket.h>

Inheritance diagram for StreamSocket:
EventHandler classbase BufferedSocket UserIOHandler ThreadSignalSocket


class  SendQueue

Public Types

enum  Type { SS_UNKNOWN , SS_USER }

Public Member Functions

 StreamSocket (Type sstype=SS_UNKNOWN)
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
virtual bool OnSetEndPoint (const irc::sockets::sockaddrs &local, const irc::sockets::sockaddrs &remote)
void WriteData (const std::string &data)
bool GetNextLine (std::string &line, char delim='\n')
size_t getSendQSize () const
SendQueueGetSendQ ()
virtual void Close ()
void Close (bool writeblock)
CullResult cull () CXX11_OVERRIDE
IOHookGetModHook (Module *mod) const
IOHookGetLastHook () const
- Public Member Functions inherited from EventHandler
int GetFd () const
bool HasFd () const
int GetEventMask () const
void SetFd (int FD)
 EventHandler ()
virtual ~EventHandler ()

Public Attributes

const Type type

Protected Member Functions

void SwapInternals (StreamSocket &other)
- Protected Member Functions inherited from EventHandler
void SwapInternals (EventHandler &other)

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 Enumeration Documentation

◆ Type

The type of socket this IOHook represents.

Member Function Documentation

◆ Close() [1/2]

void StreamSocket::Close ( )

Close the socket, remove from socket engine, etc

◆ Close() [2/2]

void StreamSocket::Close ( bool  writeblock)

If writeblock is true then only close the socket if all data has been sent. Otherwise, close immediately.

◆ cull()

CullResult StreamSocket::cull ( )

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

Gets the error message for this socket.

◆ GetLastHook()

IOHook * StreamSocket::GetLastHook ( ) const

Get the last IOHook attached to this socket

The last IOHook attached to this socket or NULL if no IOHooks are attached

◆ GetModHook()

IOHook * StreamSocket::GetModHook ( Module mod) const

Get the IOHook of a module attached to this socket

modModule whose IOHook to return
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

lineThe line read
delimThe line delimiter
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 BufferedSocket, ThreadSignalSocket, 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 ThreadSignalSocket, and UserIOHandler.

◆ OnEventHandlerError()

void StreamSocket::OnEventHandlerError ( int  errcode)

Called by the socket engine on error


Reimplemented from EventHandler.

Reimplemented in ThreadSignalSocket.

◆ OnEventHandlerRead()

void StreamSocket::OnEventHandlerRead ( )

Called by the socket engine on a read event

Implements EventHandler.

Reimplemented in ThreadSignalSocket.

◆ OnEventHandlerWrite()

void StreamSocket::OnEventHandlerWrite ( )

Called by the socket engine on a write event

Reimplemented from EventHandler.

Reimplemented in ThreadSignalSocket, and BufferedSocket.

◆ OnSetEndPoint()

bool StreamSocket::OnSetEndPoint ( const irc::sockets::sockaddrs local,
const irc::sockets::sockaddrs remote 

Called when the endpoint addresses are changed.

localThe new local endpoint.
remoteThe new remote endpoint.
true if the connection is still open, false if it has been closed

Reimplemented in UserIOHandler.

◆ SetError()

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

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

◆ SwapInternals()

void StreamSocket::SwapInternals ( StreamSocket other)

Swaps the internals of this StreamSocket with another one.

otherA StreamSocket to swap internals with.

◆ WriteData()

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

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

Member Data Documentation

◆ recvq

std::string StreamSocket::recvq

The data which has been received from the socket.

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