Logo
~Sockets~
~Examples~
~Contact~


ISocketHandler Class Reference
[Basic sockets]

Socket container class, event generator. More...

#include <ISocketHandler.h>

Inheritance diagram for ISocketHandler:

Inheritance graph
[legend]
List of all members.

Public Member Functions

virtual ~ISocketHandler ()
virtual MutexGetMutex () const=0
 Get mutex reference for threadsafe operations.
virtual void RegStdLog (StdLog *log)=0
 Register StdLog object for error callback.
virtual void LogError (Socket *p, const std::string &user_text, int err, const std::string &sys_err, loglevel_t t=LOG_LEVEL_WARNING)=0
 Log error to log class for print out / storage.
virtual void Add (Socket *)=0
 Add socket instance to socket map.
virtual void Get (SOCKET s, bool &r, bool &w, bool &e)=0
 Get status of read/write/exception file descriptor set for a socket.
virtual void Set (SOCKET s, bool bRead, bool bWrite, bool bException=true)=0
 Set read/write/exception file descriptor sets (fd_set).
virtual int Select (long sec, long usec)=0
 Wait for events, generate callbacks.
virtual int Select ()=0
 This method will not return until an event has been detected.
virtual int Select (struct timeval *tsel)=0
 Wait for events, generate callbacks.
virtual bool Valid (Socket *)=0
 Check that a socket really is handled by this socket handler.
virtual size_t GetCount ()=0
 Return number of sockets handled by this handler.
virtual bool OkToAccept (Socket *p)=0
 Override and return false to deny all incoming connections.
virtual void AddList (SOCKET s, list_t which_one, bool add)=0
 Called by Socket when a socket changes state.
virtual ISocketHandler::PoolSocketFindConnection (int type, const std::string &protocol, SocketAddress &)=0
 Find available open connection (used by connection pool).
virtual void EnablePool (bool=true)=0
 Enable connection pool (by default disabled).
virtual bool PoolEnabled ()=0
 Check pool status.
virtual void SetSocks4Host (ipaddr_t)=0
 Set socks4 server ip that all new tcp sockets should use.
virtual void SetSocks4Host (const std::string &)=0
 Set socks4 server hostname that all new tcp sockets should use.
virtual void SetSocks4Port (port_t)=0
 Set socks4 server port number that all new tcp sockets should use.
virtual void SetSocks4Userid (const std::string &)=0
 Set optional socks4 userid.
virtual void SetSocks4TryDirect (bool=true)=0
 If connection to socks4 server fails, immediately try direct connection to final host.
virtual ipaddr_t GetSocks4Host ()=0
 Get socks4 server ip.
virtual port_t GetSocks4Port ()=0
 Get socks4 port number.
virtual const std::string & GetSocks4Userid ()=0
 Get socks4 userid (optional).
virtual bool Socks4TryDirect ()=0
 Check status of socks4 try direct flag.
virtual void EnableResolver (port_t=16667)=0
 Enable asynchronous DNS.
virtual bool ResolverEnabled ()=0
 Check resolver status.
virtual int Resolve (Socket *, const std::string &host, port_t port)=0
 Queue a dns request.
virtual int Resolve (Socket *, ipaddr_t a)=0
 Do a reverse dns lookup.
virtual port_t GetResolverPort ()=0
 Get listen port of asynchronous dns server.
virtual bool ResolverReady ()=0
 Resolver thread ready for queries.
virtual void SetSlave (bool x=true)=0
 Indicates that the handler runs under SocketThread.
virtual bool IsSlave ()=0
 Indicates that the handler runs under SocketThread.

Private Member Functions

virtual void Remove (Socket *)=0
 Remove socket from socket map, used by Socket class.

Friends

class Socket

Classes

class  PoolSocket
 Connection pool class for internal use by the ISocketHandler. More...

Detailed Description

Socket container class, event generator.

Definition at line 61 of file ISocketHandler.h.


Constructor & Destructor Documentation

virtual ISocketHandler::~ISocketHandler (  )  [inline, virtual]

Definition at line 87 of file ISocketHandler.h.

00087 {}


Member Function Documentation

virtual Mutex& ISocketHandler::GetMutex (  )  const [pure virtual]

Get mutex reference for threadsafe operations.

Implemented in SocketHandler.

virtual void ISocketHandler::RegStdLog ( StdLog log  )  [pure virtual]

Register StdLog object for error callback.

Parameters:
log Pointer to log class

Implemented in SocketHandler.

virtual void ISocketHandler::LogError ( Socket p,
const std::string &  user_text,
int  err,
const std::string &  sys_err,
loglevel_t  t = LOG_LEVEL_WARNING 
) [pure virtual]

Log error to log class for print out / storage.

Implemented in SocketHandler.

Referenced by SctpSocket::AddAddress(), SctpSocket::AddConnection(), HttpPostSocket::AddFile(), UdpSocket::AddMulticastMembership(), UdpSocket::Bind(), SctpSocket::Bind(), TcpSocket::Close(), Socket::Close(), Socket::CreateSocket(), HttpdSocket::datetime2httpdate(), UdpSocket::DropMulticastMembership(), Socket::GetClientRemoteAddress(), SctpSocket::getladdrs(), UdpSocket::GetMulticastTTL(), SctpSocket::getpaddrs(), Socket::GetPort(), Socket::GetRemoteIP4(), TcpSocket::GetSsl(), TcpSocket::GetSslContext(), HttpGetSocket::HttpGetSocket(), HttpDebugSocket::Init(), TcpSocket::InitializeContext(), TcpSocket::InitSSLServer(), Socket::IpAddMembership(), Socket::IpDropMembership(), Socket::IpMulticastTTL(), Socket::IpTOS(), Socket::IpTTL(), UdpSocket::IsBroadcast(), UdpSocket::IsMulticastLoop(), TcpSocket::OnConnectTimeout(), SctpSocket::OnConnectTimeout(), HttpClientSocket::OnData(), ResolvSocket::OnDetached(), Socket::OnException(), HttpClientSocket::OnFirst(), UdpSocket::OnRead(), TcpSocket::OnRead(), SctpSocket::OnRead(), TcpSocket::OnResolved(), Socket::OnSocks4Connect(), TcpSocket::OnSocks4ConnectFailed(), Socket::OnSocks4ConnectFailed(), TcpSocket::OnSocks4Read(), Socket::OnSocks4Read(), TcpSocket::OnWrite(), SctpSocket::OnWrite(), UdpSocket::Open(), TcpSocket::Open(), SctpSocket::Open(), SctpSocket::PeelOff(), SctpSocket::RemoveAddress(), UdpSocket::SendBuf(), TcpSocket::SendBuf(), UdpSocket::SendToBuf(), UdpSocket::SetBroadcast(), Socket::SetClientRemoteAddress(), HttpPutSocket::SetFile(), Socket::SetIpHdrincl(), Socket::SetIpMulticastTTL(), Socket::SetIpOptions(), Socket::SetIpTOS(), Socket::SetIpTTL(), UdpSocket::SetMulticastLoop(), Socket::SetMulticastLoop(), UdpSocket::SetMulticastTTL(), Socket::SetNonblocking(), Socket::SetSoBroadcast(), Socket::SetSoDebug(), Socket::SetSoDontroute(), Socket::SetSoKeepalive(), Socket::SetSoLinger(), Socket::SetSoOobinline(), Socket::SetSoRcvbuf(), Socket::SetSoRcvlowat(), Socket::SetSoRcvtimeo(), Socket::SetSoReuseaddr(), Socket::SetSoSndbuf(), Socket::SetSoSndlowat(), Socket::SetSoSndtimeo(), TcpSocket::SetTcpNodelay(), Socket::SoAcceptconn(), Socket::SoError(), Socket::SoRcvbuf(), Socket::SoSndbuf(), Socket::SoType(), TcpSocket::SSLNegotiate(), TcpSocket::TryWrite(), and HTTPSocket::url_this().

virtual void ISocketHandler::Add ( Socket  )  [pure virtual]

Add socket instance to socket map.

Removal is always automatic.

Implemented in EventHandler, and SocketHandler.

Referenced by TcpSocket::OnResolved(), and SctpSocket::PeelOff().

virtual void ISocketHandler::Remove ( Socket  )  [private, pure virtual]

Remove socket from socket map, used by Socket class.

Implemented in SocketHandler.

Referenced by Socket::~Socket().

virtual void ISocketHandler::Get ( SOCKET  s,
bool &  r,
bool &  w,
bool &  e 
) [pure virtual]

Get status of read/write/exception file descriptor set for a socket.

Implemented in SocketHandler.

Referenced by TcpSocket::OnWrite(), and TcpSocket::SendBuf().

virtual void ISocketHandler::Set ( SOCKET  s,
bool  bRead,
bool  bWrite,
bool  bException = true 
) [pure virtual]

Set read/write/exception file descriptor sets (fd_set).

Implemented in SocketHandler.

Referenced by Socket::Close(), and Socket::Set().

virtual int ISocketHandler::Select ( long  sec,
long  usec 
) [pure virtual]

Wait for events, generate callbacks.

Implemented in SocketHandler.

virtual int ISocketHandler::Select (  )  [pure virtual]

This method will not return until an event has been detected.

Implemented in SocketHandler.

virtual int ISocketHandler::Select ( struct timeval *  tsel  )  [pure virtual]

Wait for events, generate callbacks.

Implemented in SocketHandler.

virtual bool ISocketHandler::Valid ( Socket  )  [pure virtual]

Check that a socket really is handled by this socket handler.

Implemented in SocketHandler.

virtual size_t ISocketHandler::GetCount (  )  [pure virtual]

Return number of sockets handled by this handler.

Implemented in SocketHandler.

virtual bool ISocketHandler::OkToAccept ( Socket p  )  [pure virtual]

Override and return false to deny all incoming connections.

Parameters:
p ListenSocket class pointer (use GetPort to identify which one)

Implemented in SocketHandler.

virtual void ISocketHandler::AddList ( SOCKET  s,
list_t  which_one,
bool  add 
) [pure virtual]

virtual ISocketHandler::PoolSocket* ISocketHandler::FindConnection ( int  type,
const std::string &  protocol,
SocketAddress  
) [pure virtual]

Find available open connection (used by connection pool).

Implemented in SocketHandler.

Referenced by TcpSocket::Open().

virtual void ISocketHandler::EnablePool ( bool  = true  )  [pure virtual]

Enable connection pool (by default disabled).

Implemented in SocketHandler.

virtual bool ISocketHandler::PoolEnabled (  )  [pure virtual]

Check pool status.

Returns:
true if connection pool is enabled

Implemented in SocketHandler.

virtual void ISocketHandler::SetSocks4Host ( ipaddr_t   )  [pure virtual]

Set socks4 server ip that all new tcp sockets should use.

Implemented in SocketHandler.

virtual void ISocketHandler::SetSocks4Host ( const std::string &   )  [pure virtual]

Set socks4 server hostname that all new tcp sockets should use.

Implemented in SocketHandler.

virtual void ISocketHandler::SetSocks4Port ( port_t   )  [pure virtual]

Set socks4 server port number that all new tcp sockets should use.

Implemented in SocketHandler.

virtual void ISocketHandler::SetSocks4Userid ( const std::string &   )  [pure virtual]

Set optional socks4 userid.

Implemented in SocketHandler.

virtual void ISocketHandler::SetSocks4TryDirect ( bool  = true  )  [pure virtual]

If connection to socks4 server fails, immediately try direct connection to final host.

Implemented in SocketHandler.

virtual ipaddr_t ISocketHandler::GetSocks4Host (  )  [pure virtual]

Get socks4 server ip.

Returns:
socks4 server ip

Implemented in SocketHandler.

virtual port_t ISocketHandler::GetSocks4Port (  )  [pure virtual]

Get socks4 port number.

Returns:
socks4 port number

Implemented in SocketHandler.

virtual const std::string& ISocketHandler::GetSocks4Userid (  )  [pure virtual]

Get socks4 userid (optional).

Returns:
socks4 userid

Implemented in SocketHandler.

virtual bool ISocketHandler::Socks4TryDirect (  )  [pure virtual]

Check status of socks4 try direct flag.

Returns:
true if direct connection should be tried if connection to socks4 server fails

Implemented in SocketHandler.

virtual void ISocketHandler::EnableResolver ( port_t  = 16667  )  [pure virtual]

Enable asynchronous DNS.

Parameters:
port Listen port of asynchronous dns server

Implemented in SocketHandler.

virtual bool ISocketHandler::ResolverEnabled (  )  [pure virtual]

Check resolver status.

Returns:
true if resolver is enabled

Implemented in SocketHandler.

virtual int ISocketHandler::Resolve ( Socket ,
const std::string &  host,
port_t  port 
) [pure virtual]

Queue a dns request.

Parameters:
host Hostname to be resolved
port Port number will be echoed in Socket::OnResolved callback

Implemented in SocketHandler.

Referenced by Socket::Resolve().

virtual int ISocketHandler::Resolve ( Socket ,
ipaddr_t  a 
) [pure virtual]

Do a reverse dns lookup.

Implemented in SocketHandler.

virtual port_t ISocketHandler::GetResolverPort (  )  [pure virtual]

Get listen port of asynchronous dns server.

Implemented in SocketHandler.

virtual bool ISocketHandler::ResolverReady (  )  [pure virtual]

Resolver thread ready for queries.

Implemented in SocketHandler.

virtual void ISocketHandler::SetSlave ( bool  x = true  )  [pure virtual]

Indicates that the handler runs under SocketThread.

Implemented in SocketHandler.

virtual bool ISocketHandler::IsSlave (  )  [pure virtual]

Indicates that the handler runs under SocketThread.

Implemented in SocketHandler.


Friends And Related Function Documentation

friend class Socket [friend]

Definition at line 63 of file ISocketHandler.h.


The documentation for this class was generated from the following file:
Page, code, and content Copyright (C) 2007 by Anders Hedström
Generated for C++ Sockets by  doxygen 1.4.4