InspIRCd
3.0
|
#include <inspsocket.h>
Public Member Functions | |
BufferedSocket (int newfd) | |
void | DoConnect (const irc::sockets::sockaddrs &dest, const irc::sockets::sockaddrs &bind, unsigned int maxtime) |
virtual void | OnConnected () |
void | OnDataReady () CXX11_OVERRIDE=0 |
virtual void | OnTimeout () |
![]() | |
StreamSocket (Type sstype=SS_UNKNOWN) | |
IOHook * | GetIOHook () const |
void | AddIOHook (IOHook *hook) |
void | DelIOHook () |
void | DoWrite () |
void | OnEventHandlerRead () CXX11_OVERRIDE |
void | OnEventHandlerError (int errcode) CXX11_OVERRIDE |
void | SetError (const std::string &err) |
const std::string & | getError () const |
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 |
SendQueue & | GetSendQ () |
virtual void | Close () |
void | Close (bool writeblock) |
CullResult | cull () CXX11_OVERRIDE |
IOHook * | GetModHook (Module *mod) const |
IOHook * | GetLastHook () const |
![]() | |
int | GetFd () const |
bool | HasFd () const |
int | GetEventMask () const |
void | SetFd (int FD) |
EventHandler () | |
virtual | ~EventHandler () |
Public Attributes | |
SocketTimeout * | Timeout |
BufferedSocketState | state |
![]() | |
const Type | type |
Protected Member Functions | |
void | OnEventHandlerWrite () CXX11_OVERRIDE |
BufferedSocketError | BeginConnect (const irc::sockets::sockaddrs &dest, const irc::sockets::sockaddrs &bind, unsigned int timeout) |
![]() | |
void | SwapInternals (StreamSocket &other) |
![]() | |
void | SwapInternals (EventHandler &other) |
Additional Inherited Members | |
![]() | |
enum | Type { SS_UNKNOWN, SS_USER } |
![]() | |
std::string | recvq |
![]() | |
int | fd |
BufferedSocket is an extendable socket class which modules can use for TCP socket support. It is fully integrated into InspIRCds socket loop and attaches its sockets to the core's instance of the SocketEngine class, meaning that all use is fully asynchronous.
To use BufferedSocket, you must inherit a class from it.
BufferedSocket::BufferedSocket | ( | int | newfd | ) |
This constructor is used to associate an existing connecting with an BufferedSocket class. The given file descriptor must be valid, and when initialized, the BufferedSocket will be placed in CONNECTED state.
void BufferedSocket::DoConnect | ( | const irc::sockets::sockaddrs & | dest, |
const irc::sockets::sockaddrs & | bind, | ||
unsigned int | maxtime | ||
) |
Begin connection to the given address This will create a socket, register with socket engine, and start the asynchronous connection process. If an error is detected at this point (such as out of file descriptors), OnError will be called; otherwise, the state will become CONNECTING.
dest | Remote endpoint to connect to. |
bind | Local endpoint to connect from. |
maxtime | Time to wait for connection |
|
virtual |
This method is called when an outbound connection on your socket is completed.
|
pure virtual |
When there is data waiting to be read on a socket, the OnDataReady() method is called.
Implements StreamSocket.
|
protectedvirtual |
Called by the socket engine on a write event
Reimplemented from StreamSocket.
|
virtual |
When an outbound connection fails, and the attempt times out, you will receive this event. The method will trigger once maxtime seconds are reached (as given in the constructor) just before the socket's descriptor is closed. A failed DNS lookup may cause this event if the DNS server is not responding, as well as a failed connect() call, because DNS lookups are nonblocking as implemented by this class.
BufferedSocketState BufferedSocket::state |
The state for this socket, either listening, connecting, connected or error.
SocketTimeout* BufferedSocket::Timeout |
Timeout object or NULL