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

#include <inspsocket.h>

Inheritance diagram for StreamSocket:
EventHandler Cullable insp::uncopiable BufferedSocket UserIOHandler

Classes

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 () override
 
void OnEventHandlerWrite () override
 
void OnEventHandlerError (int errcode) override
 
void SetError (const std::string &err)
 
const std::string & GetError () const
 
virtual void OnDataReady ()=0
 
virtual void OnError (BufferedSocketError e)=0
 
virtual bool OnSetLocalEndPoint (const irc::sockets::sockaddrs &ep)
 
virtual bool OnSetRemoteEndPoint (const irc::sockets::sockaddrs &ep)
 
void WriteData (const std::string &data)
 
size_t GetSendQSize () const
 
SendQueueGetSendQ ()
 
virtual void Close ()
 
void Close (bool writeblock)
 
Cullable::Result Cull () 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 ()
 
- Public Member Functions inherited from Cullable
virtual ~Cullable ()
 

Public Attributes

const Type type
 

Protected Attributes

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

Additional Inherited Members

- Protected Member Functions inherited from Cullable
 Cullable ()
 

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 ( )
virtual

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()

Cullable::Result StreamSocket::Cull ( )
overridevirtual

This ensures that close is called prior to destructor

Reimplemented from Cullable.

◆ DoWrite()

void StreamSocket::DoWrite ( )

Writes the contents of the send queue to the socket.

◆ GetError()

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

Retrieves the error message for this socket.

◆ GetLastHook()

IOHook * StreamSocket::GetLastHook ( ) const

Get the last IOHook attached to this socket

Returns
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

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

◆ GetSendQ()

SendQueue& StreamSocket::GetSendQ ( )
inline

Retrieves the send queue.

◆ GetSendQSize()

size_t StreamSocket::GetSendQSize ( ) const

Retrieves the current size of the send queue.

◆ OnDataReady()

virtual void StreamSocket::OnDataReady ( )
pure virtual

Called when new data is present in the receive queue.

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 I/O hook.

Implemented in UserIOHandler.

◆ OnEventHandlerError()

void StreamSocket::OnEventHandlerError ( int  errcode)
overridevirtual

Called by the socket engine when an error happens.

Parameters
errcodeThe error code provided by the operating system.

Reimplemented from EventHandler.

◆ OnEventHandlerRead()

void StreamSocket::OnEventHandlerRead ( )
overridevirtual

Called by the socket engine when a read event happens.

Implements EventHandler.

◆ OnEventHandlerWrite()

void StreamSocket::OnEventHandlerWrite ( )
overridevirtual

Called by the socket engine when a write event happens.

Reimplemented from EventHandler.

Reimplemented in BufferedSocket.

◆ OnSetLocalEndPoint()

virtual bool StreamSocket::OnSetLocalEndPoint ( const irc::sockets::sockaddrs ep)
inlinevirtual

Called when the local endpoint address is changed.

Parameters
epThe new local endpoint.
Returns
true if the connection is still open, false if it has been closed

Reimplemented in UserIOHandler.

◆ OnSetRemoteEndPoint()

virtual bool StreamSocket::OnSetRemoteEndPoint ( const irc::sockets::sockaddrs ep)
inlinevirtual

Called when the remote endpoint address is changed.

Parameters
epThe new remote endpoint.
Returns
true if the connection is still open, false if it has been closed

Reimplemented in UserIOHandler.

◆ 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

Member Data Documentation

◆ recvq

std::string StreamSocket::recvq
protected

The data which has been received from the socket.


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