ISocketHandler Class ReferenceSocket container class, event generator.
More...
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Public Member Functions | |
| virtual | ~ISocketHandler () |
| virtual IMutex & | GetMutex () 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::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. | |
Friends | |
| class | Socket |
Classes | |
| class | PoolSocket |
| Connection pool class for internal use by the ISocketHandler. More... | |
Definition at line 60 of file ISocketHandler.h.
| virtual ISocketHandler::~ISocketHandler | ( | ) | [inline, virtual] |
| virtual IMutex& ISocketHandler::GetMutex | ( | ) | const [pure virtual] |
| virtual void ISocketHandler::RegStdLog | ( | StdLog * | log | ) | [pure virtual] |
Register StdLog object for error callback.
| 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 * | ) | [protected, 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] |
| virtual int ISocketHandler::Select | ( | ) | [pure virtual] |
| virtual int ISocketHandler::Select | ( | struct timeval * | tsel | ) | [pure virtual] |
| 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 size_t ISocketHandler::GetCount | ( | ) | [pure virtual] |
| virtual bool ISocketHandler::OkToAccept | ( | Socket * | p | ) | [pure virtual] |
Override and return false to deny all incoming connections.
| p | ListenSocket class pointer (use GetPort to identify which one) |
Implemented in SocketHandler.
Called by Socket when a socket changes state.
Implemented in SocketHandler.
Referenced by Socket::Close(), StreamSocket::SetCallOnConnect(), Socket::SetCloseAndDelete(), Socket::SetDetach(), StreamSocket::SetRetryClientConnect(), and Socket::SetTimeout().
| 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] |
| virtual bool ISocketHandler::PoolEnabled | ( | ) | [pure virtual] |
| virtual void ISocketHandler::SetSocks4Host | ( | ipaddr_t | ) | [pure virtual] |
| virtual void ISocketHandler::SetSocks4Host | ( | const std::string & | ) | [pure virtual] |
| virtual void ISocketHandler::SetSocks4Port | ( | port_t | ) | [pure virtual] |
| virtual void ISocketHandler::SetSocks4Userid | ( | const std::string & | ) | [pure virtual] |
| 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] |
| virtual port_t ISocketHandler::GetSocks4Port | ( | ) | [pure virtual] |
| virtual const std::string& ISocketHandler::GetSocks4Userid | ( | ) | [pure virtual] |
| virtual bool ISocketHandler::Socks4TryDirect | ( | ) | [pure virtual] |
Check status of socks4 try direct flag.
Implemented in SocketHandler.
| virtual void ISocketHandler::EnableResolver | ( | port_t | = 16667 |
) | [pure virtual] |
Enable asynchronous DNS.
| port | Listen port of asynchronous dns server |
Implemented in SocketHandler.
| virtual bool ISocketHandler::ResolverEnabled | ( | ) | [pure virtual] |
| virtual int ISocketHandler::Resolve | ( | Socket * | , | |
| const std::string & | host, | |||
| port_t | port | |||
| ) | [pure virtual] |
Queue a dns request.
| host | Hostname to be resolved | |
| port | Port number will be echoed in Socket::OnResolved callback |
Implemented in SocketHandler.
Referenced by Socket::Resolve().
| virtual port_t ISocketHandler::GetResolverPort | ( | ) | [pure virtual] |
| virtual bool ISocketHandler::ResolverReady | ( | ) | [pure virtual] |
| 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] |
| virtual bool ISocketHandler::IsSlave | ( | ) | [pure virtual] |
friend class Socket [friend] |
Definition at line 62 of file ISocketHandler.h.
1.4.4