The InspIRCd Project
Home | Developers | Wiki | Forums | Bug Tracker | SVN | Download
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

ListenSocketBase Class Reference

This class handles incoming connections on client ports. More...

#include <socket.h>

Inheritance diagram for ListenSocketBase:

Inheritance graph
[legend]
Collaboration diagram for ListenSocketBase:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ListenSocketBase (InspIRCd *Instance, int port, const std::string &addr)
 Create a new listening socket.
void HandleEvent (EventType et, int errornum=0)
 Handle an I/O event.
 ~ListenSocketBase ()
 Close the socket.
void SetDescription (const std::string &description)
 Set descriptive text.
const std::stringGetDescription ()
 Get description for socket.
int GetPort ()
 Get port number for socket.
std::stringGetIP ()
 Get IP address socket is bound to.
void AcceptInternal ()
 Handles sockets internals crap of a connection, convenience wrapper really.
virtual void OnAcceptReady (const std::string &ipconnectedto, int fd, const std::string &incomingip)=0
 Called when a new connection has successfully been accepted on this listener.

Protected Attributes

InspIRCdServerInstance
 The creator/owner of this object.
std::string desc
 Socket description (shown in stats p).
int family
 Socket address family.
std::string bind_addr
 Address socket is bound to.
int bind_port
 Port socket is bound to.

Static Protected Attributes

static sockaddr * sock_us = NULL
static sockaddr * client = NULL
static sockaddr * raddr = NULL
static unsigned int socketcount = 0

Detailed Description

This class handles incoming connections on client ports.

It will create a new User for every valid connection and assign it a file descriptor.

Definition at line 148 of file socket.h.


Constructor & Destructor Documentation

ListenSocketBase::ListenSocketBase InspIRCd Instance,
int  port,
const std::string addr
 

Create a new listening socket.

Definition at line 27 of file listensocket.cpp.

References SocketEngine::AddFd(), InspIRCd::BindSocket(), client, DEBUG, family, EventHandler::fd, LogManager::Log(), InspIRCd::Logs, irc::sockets::OpenTCPSocket(), raddr, InspIRCd::SE, ServerInstance, EventHandler::SetFd(), sock_us, and socketcount.

ListenSocketBase::~ListenSocketBase  ) 
 

Close the socket.

Definition at line 54 of file listensocket.cpp.

References client, SocketEngine::Close(), DEBUG, SocketEngine::DelFd(), EventHandler::fd, LogManager::Log(), InspIRCd::Logs, raddr, InspIRCd::SE, ServerInstance, SocketEngine::Shutdown(), sock_us, and socketcount.


Member Function Documentation

void ListenSocketBase::AcceptInternal  ) 
 

Handles sockets internals crap of a connection, convenience wrapper really.

Definition at line 74 of file listensocket.cpp.

References SocketEngine::Accept(), client, SocketEngine::Close(), DEBUG, SocketEngine::GetMaxFds(), SocketEngine::GetSockName(), LogManager::Log(), InspIRCd::Logs, MAXBUF, SocketEngine::NonBlocking(), OnAcceptReady(), raddr, InspIRCd::SE, ServerInstance, SocketEngine::Shutdown(), sock_us, InspIRCd::stats, serverstats::statsAccept, and serverstats::statsRefused.

Referenced by HandleEvent().

const std::string& ListenSocketBase::GetDescription  )  [inline]
 

Get description for socket.

Definition at line 189 of file socket.h.

std::string& ListenSocketBase::GetIP  )  [inline]
 

Get IP address socket is bound to.

Definition at line 201 of file socket.h.

int ListenSocketBase::GetPort  )  [inline]
 

Get port number for socket.

Reimplemented in MsSQLListener, MySQLListener, and SQLiteListener.

Definition at line 195 of file socket.h.

void ListenSocketBase::HandleEvent EventType  et,
int  errornum = 0
[virtual]
 

Handle an I/O event.

Implements EventHandler.

Definition at line 180 of file listensocket.cpp.

References AcceptInternal(), DEBUG, DEFAULT, EVENT_ERROR, EVENT_READ, EVENT_WRITE, LogManager::Log(), InspIRCd::Logs, and ServerInstance.

virtual void ListenSocketBase::OnAcceptReady const std::string ipconnectedto,
int  fd,
const std::string incomingip
[pure virtual]
 

Called when a new connection has successfully been accepted on this listener.

Parameters:
ipconnectedto The IP address the connection arrived on
fd The file descriptor of the new connection
incomingip The IP from which the connection was made

Implemented in HttpListener, MsSQLListener, MySQLListener, SQLiteListener, ServerSocketListener, and ClientListenSocket.

Referenced by AcceptInternal().

void ListenSocketBase::SetDescription const std::string description  )  [inline]
 

Set descriptive text.

Definition at line 183 of file socket.h.


Member Data Documentation

std::string ListenSocketBase::bind_addr [protected]
 

Address socket is bound to.

Definition at line 159 of file socket.h.

int ListenSocketBase::bind_port [protected]
 

Port socket is bound to.

Definition at line 161 of file socket.h.

Referenced by ServerSocketListener::OnAcceptReady(), and ClientListenSocket::OnAcceptReady().

sockaddr * ListenSocketBase::client = NULL [static, protected]
 

Definition at line 165 of file socket.h.

Referenced by AcceptInternal(), ListenSocketBase(), ClientListenSocket::OnAcceptReady(), and ~ListenSocketBase().

std::string ListenSocketBase::desc [protected]
 

Socket description (shown in stats p).

Definition at line 155 of file socket.h.

int ListenSocketBase::family [protected]
 

Socket address family.

Definition at line 157 of file socket.h.

Referenced by ListenSocketBase().

sockaddr * ListenSocketBase::raddr = NULL [static, protected]
 

Definition at line 167 of file socket.h.

Referenced by AcceptInternal(), ListenSocketBase(), and ~ListenSocketBase().

InspIRCd* ListenSocketBase::ServerInstance [protected]
 

The creator/owner of this object.

Definition at line 153 of file socket.h.

Referenced by AcceptInternal(), HandleEvent(), ListenSocketBase(), ServerSocketListener::OnAcceptReady(), HttpListener::OnAcceptReady(), ClientListenSocket::OnAcceptReady(), and ~ListenSocketBase().

sockaddr * ListenSocketBase::sock_us = NULL [static, protected]
 

Reimplemented in MsSQLListener, MySQLListener, and SQLiteListener.

Definition at line 163 of file socket.h.

Referenced by AcceptInternal(), ListenSocketBase(), and ~ListenSocketBase().

unsigned int ListenSocketBase::socketcount = 0 [static, protected]
 

Definition at line 169 of file socket.h.

Referenced by ListenSocketBase(), and ~ListenSocketBase().


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