Logo
~Sockets~
~Examples~
~Contact~


ISocketHandler Class Reference
[Basic sockets]

Socket container class, event generator. More...

#include <ISocketHandler.h>

Inheritance diagram for ISocketHandler:

List of all members.


Public Member Functions

virtual ~ISocketHandler ()
virtual ISocketHandlerCreate (StdLog *=NULL)=0
 Return another instance.
virtual ISocketHandlerCreate (IMutex &, ISocketHandler &, StdLog *=NULL)=0
 Return another instance.
virtual bool ParentHandlerIsValid ()=0
 Handler created with parent.
virtual ISocketHandlerParentHandler ()=0
 Get parent sockethandler.
virtual ISocketHandlerGetRandomHandler ()=0
 Get thread handler with least connections.
virtual ISocketHandlerGetEffectiveHandler ()=0
 Return parent handler if valid, otherwise return normal handler.
virtual void SetNumberOfThreads (size_t n)=0
 Enable threading.
virtual bool IsThreaded ()=0
 Threading is enabled.
virtual void EnableRelease ()=0
 Enable select release.
virtual void Release ()=0
 Make select release.
virtual IMutexGetMutex () 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 ISocketHandler_Add (Socket *, bool bRead, bool bWrite)=0
 Set read/write/exception file descriptor sets (fd_set).
virtual void ISocketHandler_Mod (Socket *, bool bRead, bool bWrite)=0
virtual void ISocketHandler_Del (Socket *)=0
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 bool Valid (socketuid_t)=0
 Preferred method - Check that a socket still is handled by this socket handler.
virtual size_t GetCount ()=0
 Return number of sockets handled by this handler.
virtual size_t MaxCount ()=0
 Return maximum number of sockets allowed.
virtual bool OkToAccept (Socket *p)=0
 Override and return false to deny all incoming connections.
virtual const std::map< SOCKET,
Socket * > & 
AllSockets ()=0
 Use with care, always lock with h.GetMutex() if multithreaded.
virtual size_t MaxTcpLineSize ()=0
 Override to accept longer lines than TCP_LINE_SIZE.
virtual void SetCallOnConnect (bool=true)=0
virtual void SetDetach (bool=true)=0
virtual void SetTimeout (bool=true)=0
virtual void SetRetry (bool=true)=0
virtual void SetClose (bool=true)=0
virtual
ISocketHandler::PoolSocket
FindConnection (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 bool Resolving (Socket *)=0
 Returns true if socket waiting for a resolve event.
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.

Protected Member Functions

virtual void Remove (Socket *)=0
 Remove socket from socket map, used by Socket class.
virtual int ISocketHandler_Select (struct timeval *)=0
 Actual call to select().

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 53 of file ISocketHandler.h.


Constructor & Destructor Documentation

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

Definition at line 79 of file ISocketHandler.h.

00079 {}


Member Function Documentation

virtual ISocketHandler* ISocketHandler::Create ( StdLog = NULL  )  [pure virtual]

Return another instance.

Implemented in SocketHandler, and SocketHandlerEp.

Referenced by SocketHandlerThread::Run().

virtual ISocketHandler* ISocketHandler::Create ( IMutex ,
ISocketHandler ,
StdLog = NULL 
) [pure virtual]

Return another instance.

Implemented in SocketHandler, and SocketHandlerEp.

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

Handler created with parent.

Implemented in SocketHandler.

virtual ISocketHandler& ISocketHandler::ParentHandler (  )  [pure virtual]

Get parent sockethandler.

Implemented in SocketHandler.

virtual ISocketHandler& ISocketHandler::GetRandomHandler (  )  [pure virtual]

Get thread handler with least connections.

Implemented in SocketHandler.

virtual ISocketHandler& ISocketHandler::GetEffectiveHandler (  )  [pure virtual]

Return parent handler if valid, otherwise return normal handler.

Implemented in SocketHandler.

virtual void ISocketHandler::SetNumberOfThreads ( size_t  n  )  [pure virtual]

Enable threading.

Implemented in SocketHandler.

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

Threading is enabled.

Implemented in SocketHandler.

virtual void ISocketHandler::EnableRelease (  )  [pure virtual]

Enable select release.

Implemented in SocketHandler.

Referenced by SocketHandlerThread::Run().

virtual void ISocketHandler::Release (  )  [pure virtual]

Make select release.

Implemented in SocketHandler.

Referenced by ListenSocket< X >::OnRead().

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

Get mutex reference for threadsafe operations.

Implemented in SocketHandler.

Referenced by SocketHandler::GetRandomHandler(), and ListenSocket< X >::OnRead().

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(), HttpGetSocket::DoConnect(), UdpSocket::DropMulticastMembership(), Socket::GetClientRemoteAddress(), SctpSocket::getladdrs(), UdpSocket::GetMulticastTTL(), SctpSocket::getpaddrs(), Socket::GetPort(), Socket::GetRemoteIP4(), TcpSocket::GetSsl(), TcpSocket::GetSslContext(), 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(), HTTPSocket::OnLine(), 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(), TcpSocket::SendFromOutputBuffer(), UdpSocket::SendToBuf(), UdpSocket::SetBroadcast(), Socket::SetClientRemoteAddress(), HttpPutSocket::SetFile(), Socket::SetIpHdrincl(), Socket::SetIpMulticastTTL(), Socket::SetIpOptions(), Socket::SetIpTOS(), Socket::SetIpTTL(), UdpSocket::SetMulticastDefaultInterface(), 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(), HTTPSocket::url_this(), and TcpSocket::UseCertificateChainFile().

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

Add socket instance to socket map.

Removal is always automatic.

Implemented in EventHandler, and SocketHandler.

Referenced by ListenSocket< X >::OnRead(), TcpSocket::OnResolved(), and SctpSocket::PeelOff().

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

Remove socket from socket map, used by Socket class.

Implemented in SocketHandler.

Referenced by Socket::~Socket().

virtual int ISocketHandler::ISocketHandler_Select ( struct timeval *   )  [protected, pure virtual]

Actual call to select().

Implemented in SocketHandler.

virtual void ISocketHandler::ISocketHandler_Add ( Socket ,
bool  bRead,
bool  bWrite 
) [pure virtual]

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

Implemented in SocketHandler.

virtual void ISocketHandler::ISocketHandler_Mod ( Socket ,
bool  bRead,
bool  bWrite 
) [pure virtual]

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

Implemented in SocketHandler.

Referenced by Socket::Close().

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

Wait for events, generate callbacks.

Implemented in SocketHandler.

Referenced by SocketHandlerThread::Run().

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.

Referenced by SocketStream::IStreamRead(), SocketStream::IStreamWrite(), and ResolvSocket::OnLine().

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

Preferred method - Check that a socket still 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.

Referenced by SocketHandler::GetRandomHandler().

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

Return maximum number of sockets allowed.

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 const std::map<SOCKET, Socket *>& ISocketHandler::AllSockets (  )  [pure virtual]

Use with care, always lock with h.GetMutex() if multithreaded.

Implemented in SocketHandler.

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

Override to accept longer lines than TCP_LINE_SIZE.

Implemented in SocketHandler.

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

Implemented in SocketHandler.

Referenced by Socket::SetCallOnConnect().

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

Implemented in SocketHandler.

Referenced by Socket::SetDetach().

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

Implemented in SocketHandler.

Referenced by Socket::SetTimeout().

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

Implemented in SocketHandler.

Referenced by Socket::SetRetryClientConnect().

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

Implemented in SocketHandler.

Referenced by Socket::SetCloseAndDelete().

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 bool ISocketHandler::Resolving ( Socket  )  [pure virtual]

Returns true if socket waiting for a resolve event.

Implemented in SocketHandler.

Referenced by ResolvSocket::OnLine().

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 55 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