![]() |
Socket Class ReferenceSocket base class.
More...
|
Public Member Functions | |
Socket (ISocketHandler &) | |
"Default" constructor | |
virtual | ~Socket () |
virtual Socket * | Create () |
Socket class instantiation method. | |
virtual void | Init () |
CTcpSocket uses this to create its ICrypt member variable. | |
void | Attach (SOCKET s) |
Assign this socket a file descriptor created by a call to socket() or otherwise. | |
SOCKET | GetSocket () |
Return file descriptor assigned to this socket. | |
virtual int | Close () |
Close connection immediately - internal use. | |
SOCKET | CreateSocket (int af, int type, const std::string &protocol="") |
Create a socket file descriptor. | |
void | Set (bool bRead, bool bWrite, bool bException=true) |
Add file descriptor to sockethandler fd_set's. | |
bool | Ready () |
Returns true when socket file descriptor is valid, socket connection is established, and socket is not about to be closed. | |
virtual void | OnRead () |
Called when there is something to be read from the file descriptor. | |
virtual void | OnWrite () |
Called when there is room for another write on the file descriptor. | |
virtual void | OnException () |
Called on socket exception. | |
virtual void | OnDelete () |
Called before a socket class is deleted by the ISocketHandler. | |
virtual void | OnConnect () |
Called when a connection has completed. | |
virtual void | OnAccept () |
Called when an incoming connection has been completed. | |
virtual void | OnLine (const std::string &) |
Called when a complete line has been read and the socket is in line protocol mode. | |
virtual void | OnConnectFailed () |
Called on connect timeout (5s). | |
virtual void | OnOptions (int family, int type, int protocol, SOCKET)=0 |
Called when a socket is created, to set socket options. | |
virtual bool | OnConnectRetry () |
Connection retry callback - return false to abort connection attempts. | |
virtual void | OnReconnect () |
a reconnect has been made | |
virtual void | OnDisconnect () |
When a socket is set to reconnect, and a disconnect has been detected. | |
virtual bool | CheckConnect () |
Check whether a connection has been established. | |
virtual void | SetLineProtocol (bool=true) |
Enable the OnLine callback. | |
bool | LineProtocol () |
Check line protocol mode. | |
void | SetDeleteByHandler (bool=true) |
Set delete by handler true when you want the sockethandler to delete the socket instance after use. | |
bool | DeleteByHandler () |
Check delete by handler flag. | |
void | SetCloseAndDelete (bool=true) |
Set close and delete to terminate the connection. | |
bool | CloseAndDelete () |
Check close and delete flag. | |
void | SetConnecting (bool=true) |
Socket should call CheckConnect on next write event from select(). | |
bool | Connecting () |
Check connecting flag. | |
time_t | GetConnectTime () |
Number of seconds the socket has been connected. | |
void | SetRemoteAddress (SocketAddress &) |
Used by ListenSocket. | |
std::auto_ptr< SocketAddress > | GetRemoteSocketAddress () |
Returns address of remote end. | |
ipaddr_t | GetRemoteIP4 () |
Returns address of remote end: ipv4. | |
port_t | GetRemotePort () |
Returns remote port number: ipv4 and ipv6. | |
std::string | GetRemoteAddress () |
Returns remote ip as string? ipv4 and ipv6. | |
std::string | GetRemoteHostname () |
ipv4 and ipv6(not implemented) | |
ISocketHandler & | Handler () const |
Returns reference to sockethandler that owns the socket. | |
ISocketHandler & | MasterHandler () const |
Returns reference to sockethandler that owns the socket. | |
bool | SetNonblocking (bool) |
Set socket non-block operation. | |
bool | SetNonblocking (bool, SOCKET) |
Set socket non-block operation. | |
time_t | Uptime () |
Total lifetime of instance. | |
Socket * | GetParent () |
Returns pointer to ListenSocket that created this instance on an incoming connection. | |
void | SetParent (Socket *) |
Used by ListenSocket to set parent pointer of newly created socket instance. | |
virtual port_t | GetPort () |
Get listening port from ListenSocket<>. | |
void | SetClientRemoteAddress (SocketAddress &) |
Set address/port of last connect() call. | |
std::auto_ptr< SocketAddress > | GetClientRemoteAddress () |
Get address/port of last connect() call. | |
void | SetCallOnConnect (bool x=true) |
Instruct socket to call OnConnect callback next sockethandler cycle. | |
bool | CallOnConnect () |
Check call on connect flag. | |
void | SetReuse (bool x) |
Socket option SO_REUSEADDR. | |
void | SetKeepalive (bool x) |
Socket option SO_KEEPALIVE. | |
void | SetConnectTimeout (int x) |
Set timeout to use for connection attempt. | |
int | GetConnectTimeout () |
Return number of seconds to wait for a connection. | |
void | DisableRead (bool x=true) |
Ignore read events for an output only socket. | |
bool | IsDisableRead () |
Check ignore read events flag. | |
void | SetRetryClientConnect (bool x=true) |
Set flag to initiate a connection attempt after a connection timeout. | |
bool | RetryClientConnect () |
Check if a connection attempt should be made. | |
virtual void | SendBuf (const char *, size_t, int=0) |
Common interface for SendBuf used by Tcp and Udp sockets. | |
virtual void | Send (const std::string &, int=0) |
Common interface for Send used by Tcp and Udp sockets. | |
void | SetConnected (bool=true) |
Set connected status. | |
bool | IsConnected () |
Check connected status. | |
void | SetFlushBeforeClose (bool=true) |
Set flush before close to make a tcp socket completely empty its output buffer before closing the connection. | |
bool | GetFlushBeforeClose () |
Check flush before status. | |
void | SetConnectionRetry (int n) |
Define number of connection retries (tcp only). | |
int | GetConnectionRetry () |
Get number of maximum connection retries (tcp only). | |
void | IncreaseConnectionRetries () |
Increase number of actual connection retries (tcp only). | |
int | GetConnectionRetries () |
Get number of actual connection retries (tcp only). | |
void | ResetConnectionRetries () |
Reset actual connection retries (tcp only). | |
void | SetErasedByHandler (bool x=true) |
Set flag indicating the socket is being actively deleted by the sockethandler. | |
bool | ErasedByHandler () |
Get value of flag indicating socket is deleted by sockethandler. | |
time_t | TimeSinceClose () |
Return number of seconds since socket was ordered to close. | |
void | SetShutdown (int) |
Set shutdown status. | |
int | GetShutdown () |
Get shutdown status. | |
virtual uint64_t | GetBytesSent (bool clear=false) |
virtual uint64_t | GetBytesReceived (bool clear=false) |
unsigned long int | Random () |
virtual void | OnSSLConnect () |
SSL client/server support - internal use. | |
virtual void | OnSSLAccept () |
SSL client/server support - internal use. | |
virtual void | OnSSLConnectFailed () |
SSL negotiation failed for client connect. | |
virtual void | OnSSLAcceptFailed () |
SSL negotiation failed for server accept. | |
virtual bool | SSLNegotiate () |
new SSL support | |
bool | IsSSL () |
Check if SSL is Enabled for this TcpSocket. | |
void | EnableSSL (bool x=true) |
Enable SSL operation for a TcpSocket. | |
bool | IsSSLNegotiate () |
Still negotiating ssl connection. | |
void | SetSSLNegotiate (bool x=true) |
Set flag indicating ssl handshaking still in progress. | |
bool | IsSSLServer () |
OnAccept called with SSL Enabled. | |
void | SetSSLServer (bool x=true) |
Set flag indicating that this is a TcpSocket with incoming SSL connection. | |
virtual SSL_CTX * | GetSslContext () |
SSL; Get pointer to ssl context structure. | |
virtual SSL * | GetSsl () |
SSL; Get pointer to ssl structure. | |
void | SetIsClient () |
Client = connecting TcpSocket. | |
void | SetSocketType (int x) |
Socket type from socket() call. | |
int | GetSocketType () |
Socket type from socket() call. | |
void | SetSocketProtocol (const std::string &x) |
Protocol type from socket() call. | |
const std::string & | GetSocketProtocol () |
Protocol type from socket() call. | |
void | SetRetain () |
Instruct a client socket to stay open in the connection pool after use. | |
bool | Retain () |
Check retain flag. | |
void | SetLost () |
Connection lost - error while reading/writing from a socket - TcpSocket only. | |
bool | Lost () |
Check connection lost status flag, used by TcpSocket only. | |
void | CopyConnection (Socket *sock) |
Copy connection parameters from sock. | |
virtual void | OnSocks4Connect () |
Socks4 client support internal use. | |
virtual void | OnSocks4ConnectFailed () |
Socks4 client support internal use. | |
virtual bool | OnSocks4Read () |
Socks4 client support internal use. | |
bool | Socks4 () |
socket still in socks4 negotiation mode | |
void | SetSocks4 (bool x=true) |
Set flag indicating Socks4 handshaking in progress. | |
void | SetSocks4Host (ipaddr_t a) |
Set socks4 server host address to use. | |
void | SetSocks4Host (const std::string &) |
Set socks4 server hostname to use. | |
void | SetSocks4Port (port_t p) |
Socks4 server port to use. | |
void | SetSocks4Userid (const std::string &x) |
Provide a socks4 userid if required by the socks4 server. | |
ipaddr_t | GetSocks4Host () |
Get the ip address of socks4 server to use. | |
port_t | GetSocks4Port () |
Get the socks4 server port to use. | |
const std::string & | GetSocks4Userid () |
Get socks4 userid. | |
int | Resolve (const std::string &host, port_t port=0) |
Request an asynchronous dns resolution. | |
virtual void | OnResolved (int id, ipaddr_t a, port_t port) |
Callback returning a resolved address. | |
int | Resolve (ipaddr_t a) |
Request asynchronous reverse dns lookup. | |
virtual void | OnReverseResolved (int id, const std::string &name) |
Callback returning reverse resolve results. | |
virtual void | OnResolveFailed (int id) |
Callback indicating failed dns lookup. | |
virtual void | OnDetached () |
Callback fires when a new socket thread has started and this socket is ready for operation again. | |
void | SetDetach (bool x=true) |
Internal use. | |
bool | IsDetach () |
Check detach flag. | |
void | SetDetached (bool x=true) |
Internal use. | |
const bool | IsDetached () const |
Check detached flag. | |
bool | Detach () |
Order this socket to start its own thread and call OnDetached when ready for operation. | |
void | SetSlaveHandler (ISocketHandler *) |
Store the slave sockethandler pointer. | |
void | DetachSocket () |
Create new thread for this socket to run detached in. | |
void | SetTrafficMonitor (IFile *p) |
Protected Member Functions | |
Socket (const Socket &) | |
do not allow use of copy constructor | |
IFile * | GetTrafficMonitor () |
Protected Attributes | |
RandomNumber | m_prng |
Random number generator. | |
Private Member Functions | |
Socket () | |
default constructor not available | |
Socket & | operator= (const Socket &) |
assignment operator not available. | |
Private Attributes | |
ISocketHandler & | m_handler |
Reference of ISocketHandler in control of this socket. | |
SOCKET | m_socket |
File descriptor. | |
bool | m_bDel |
Delete by handler flag. | |
bool | m_bClose |
Close and delete flag. | |
bool | m_bConnecting |
Flag indicating connection in progress. | |
time_t | m_tConnect |
Time in seconds when connection was established. | |
time_t | m_tCreate |
Time in seconds when this socket was created. | |
bool | m_line_protocol |
Line protocol mode flag. | |
Socket * | m_parent |
Pointer to ListenSocket class, valid for incoming sockets. | |
bool | m_call_on_connect |
OnConnect will be called next ISocketHandler cycle if true. | |
bool | m_opt_reuse |
Socket option reuseaddr. | |
bool | m_opt_keepalive |
Socket option keep-alive. | |
int | m_connect_timeout |
Connection timeout (seconds). | |
bool | m_b_disable_read |
Disable checking for read events. | |
bool | m_b_retry_connect |
Try another connection attempt next ISocketHandler cycle. | |
bool | m_connected |
Socket is connected (tcp/udp). | |
bool | m_flush_before_close |
Send all data before closing (default true). | |
int | m_connection_retry |
Maximum connection retries (tcp). | |
int | m_retries |
Actual number of connection retries (tcp). | |
bool | m_b_erased_by_handler |
Set by handler before delete. | |
time_t | m_tClose |
Time in seconds when ordered to close. | |
int | m_shutdown |
Shutdown status. | |
std::auto_ptr< SocketAddress > | m_client_remote_address |
Address of last connect(). | |
std::auto_ptr< SocketAddress > | m_remote_address |
Remote end address. | |
IFile * | m_traffic_monitor |
bool | m_b_enable_ssl |
Enable SSL for this TcpSocket. | |
bool | m_b_ssl |
ssl negotiation mode (TcpSocket) | |
bool | m_b_ssl_server |
True if this is an incoming ssl TcpSocket connection. | |
int | m_socket_type |
Type of socket, from socket() call. | |
std::string | m_socket_protocol |
Protocol, from socket() call. | |
bool | m_bClient |
only client connections are pooled | |
bool | m_bRetain |
keep connection on close | |
bool | m_bLost |
connection lost | |
bool | m_bSocks4 |
socks4 negotiation mode (TcpSocket) | |
ipaddr_t | m_socks4_host |
socks4 server address | |
port_t | m_socks4_port |
socks4 server port number | |
std::string | m_socks4_userid |
socks4 server usedid | |
bool | m_detach |
Socket ordered to detach flag. | |
bool | m_detached |
Socket has been detached. | |
SocketThread * | m_pThread |
Detach socket thread class pointer. | |
ISocketHandler * | m_slave_handler |
Actual sockethandler while detached. | |
Friends | |
class | ISocketHandler |
Classes | |
class | SocketThread |
Detached socket run thread. More... |
Definition at line 62 of file Socket.h.
Socket::Socket | ( | ISocketHandler & | ) |
"Default" constructor
Definition at line 65 of file Socket.cpp.
00066 :m_prng( true ) 00067 ,m_handler(h) 00068 ,m_socket( INVALID_SOCKET ) 00069 ,m_bDel(false) 00070 ,m_bClose(false) 00071 ,m_bConnecting(false) 00072 ,m_tCreate(time(NULL)) 00073 ,m_line_protocol(false) 00074 #ifdef ENABLE_IPV6 00075 ,m_ipv6(false) 00076 #endif 00077 ,m_parent(NULL) 00078 ,m_call_on_connect(false) 00079 ,m_opt_reuse(true) 00080 ,m_opt_keepalive(true) 00081 ,m_connect_timeout(5) 00082 ,m_b_disable_read(false) 00083 ,m_b_retry_connect(false) 00084 ,m_connected(false) 00085 ,m_flush_before_close(true) 00086 ,m_connection_retry(0) 00087 ,m_retries(0) 00088 ,m_b_erased_by_handler(false) 00089 ,m_tClose(0) 00090 ,m_shutdown(0) 00091 ,m_client_remote_address(NULL) 00092 ,m_remote_address(NULL) 00093 ,m_traffic_monitor(NULL) 00094 #ifdef HAVE_OPENSSL 00095 ,m_b_enable_ssl(false) 00096 ,m_b_ssl(false) 00097 ,m_b_ssl_server(false) 00098 #endif 00099 #ifdef ENABLE_POOL 00100 ,m_socket_type(0) 00101 ,m_bClient(false) 00102 ,m_bRetain(false) 00103 ,m_bLost(false) 00104 #endif 00105 #ifdef ENABLE_SOCKS4 00106 ,m_bSocks4(false) 00107 ,m_socks4_host(h.GetSocks4Host()) 00108 ,m_socks4_port(h.GetSocks4Port()) 00109 ,m_socks4_userid(h.GetSocks4Userid()) 00110 #endif 00111 #ifdef ENABLE_DETACH 00112 ,m_detach(false) 00113 ,m_detached(false) 00114 ,m_pThread(NULL) 00115 ,m_slave_handler(NULL) 00116 #endif 00117 { 00118 }
Socket::~Socket | ( | ) | [virtual] |
Definition at line 121 of file Socket.cpp.
References Close(), Handler(), INVALID_SOCKET, m_bRetain, m_socket, and ISocketHandler::Remove().
00122 { 00123 Handler().Remove(this); 00124 if (m_socket != INVALID_SOCKET 00125 #ifdef ENABLE_POOL 00126 && !m_bRetain 00127 #endif 00128 ) 00129 { 00130 Close(); 00131 } 00132 }
Socket::Socket | ( | const Socket & | ) | [protected] |
Socket::Socket | ( | ) | [inline, private] |
Socket * Socket::Create | ( | ) | [virtual] |
Socket class instantiation method.
Used when a "non-standard" constructor needs to be used for the socket class. Note: the socket class still needs the "default" constructor with one ISocketHandler& as input parameter.
Definition at line 649 of file Socket.cpp.
Referenced by SctpSocket::PeelOff().
void Socket::Init | ( | ) | [virtual] |
CTcpSocket uses this to create its ICrypt member variable.
The ICrypt member variable is created by a virtual method, therefore it can't be called directly from the CTcpSocket constructor. Also used to determine if incoming HTTP connection is normal (port 80) or ssl (port 443).
Reimplemented in CTcpSocket, and HttpDebugSocket.
Definition at line 135 of file Socket.cpp.
void Socket::Attach | ( | SOCKET | s | ) |
Assign this socket a file descriptor created by a call to socket() or otherwise.
Definition at line 352 of file Socket.cpp.
References m_socket.
Referenced by UdpSocket::Bind(), SctpSocket::Bind(), CopyConnection(), UdpSocket::CreateConnection(), UdpSocket::Open(), TcpSocket::Open(), SctpSocket::Open(), SctpSocket::PeelOff(), and UdpSocket::SendToBuf().
00353 { 00354 m_socket = s; 00355 }
SOCKET Socket::GetSocket | ( | ) |
Return file descriptor assigned to this socket.
Definition at line 358 of file Socket.cpp.
References m_socket.
Referenced by SctpSocket::AddAddress(), SctpSocket::AddConnection(), UdpSocket::AddMulticastMembership(), UdpSocket::Bind(), SctpSocket::Bind(), CopyConnection(), UdpSocket::CreateConnection(), UdpSocket::DropMulticastMembership(), SctpSocket::getladdrs(), UdpSocket::GetMulticastTTL(), SctpSocket::getpaddrs(), UdpSocket::IsBroadcast(), UdpSocket::IsMulticastLoop(), UdpSocket::OnRead(), TcpSocket::OnRead(), SctpSocket::OnRead(), TcpSocket::OnSSLAccept(), TcpSocket::OnSSLConnect(), TcpSocket::OnWrite(), UdpSocket::Open(), SctpSocket::Open(), SctpSocket::PeelOff(), SctpSocket::RemoveAddress(), UdpSocket::SendBuf(), TcpSocket::SendBuf(), UdpSocket::SendToBuf(), UdpSocket::SetBroadcast(), UdpSocket::SetMulticastLoop(), and UdpSocket::SetMulticastTTL().
00359 { 00360 return m_socket; 00361 }
int Socket::Close | ( | ) | [virtual] |
Close connection immediately - internal use.
Reimplemented in ListenSocket< X >, and TcpSocket.
Definition at line 236 of file Socket.cpp.
References ISocketHandler::AddList(), closesocket, DEB, Errno, GetShutdown(), Handler(), INVALID_SOCKET, IsConnected(), LIST_CALLONCONNECT, LIST_CLOSE, LIST_CONNECTING, LIST_DETACH, LIST_RETRY, LOG_LEVEL_ERROR, LOG_LEVEL_WARNING, ISocketHandler::LogError(), m_socket, Set(), SetNonblocking(), and StrError.
Referenced by TcpSocket::Close(), ~Socket(), and UdpSocket::~UdpSocket().
00237 { 00238 DEB( fprintf(stderr, " fd %d\n", m_socket);) 00239 if (m_socket == INVALID_SOCKET) // this could happen 00240 { 00241 Handler().LogError(this, "Socket::Close", 0, "file descriptor invalid", LOG_LEVEL_WARNING); 00242 return 0; 00243 } 00244 int n; 00245 SetNonblocking(true); 00246 if (IsConnected() && !(GetShutdown() & SHUT_WR)) 00247 { 00248 if (shutdown(m_socket, SHUT_WR) == -1) 00249 { 00250 // failed... 00251 Handler().LogError(this, "shutdown", Errno, StrError(Errno), LOG_LEVEL_ERROR); 00252 } 00253 } 00254 // 00255 char tmp[100]; 00256 if ((n = recv(m_socket,tmp,100,0)) == -1) 00257 { 00258 // Handler().LogError(this, "read() after shutdown", Errno, StrError(Errno), LOG_LEVEL_WARNING); 00259 } 00260 else 00261 { 00262 if (n) 00263 { 00264 Handler().LogError(this, "read() after shutdown", n, "bytes read", LOG_LEVEL_WARNING); 00265 } 00266 } 00267 if ((n = closesocket(m_socket)) == -1) 00268 { 00269 // failed... 00270 Handler().LogError(this, "close", Errno, StrError(Errno), LOG_LEVEL_ERROR); 00271 } 00272 Set(false, false, false); // remove from fd_set's 00273 Handler().AddList(m_socket, LIST_CALLONCONNECT, false); 00274 #ifdef ENABLE_DETACH 00275 Handler().AddList(m_socket, LIST_DETACH, false); 00276 #endif 00277 Handler().AddList(m_socket, LIST_CONNECTING, false); 00278 Handler().AddList(m_socket, LIST_RETRY, false); 00279 Handler().AddList(m_socket, LIST_CLOSE, false); 00280 m_socket = INVALID_SOCKET; 00281 DEB( fprintf(stderr, " fd %d\n", m_socket);) 00282 return n; 00283 }
SOCKET Socket::CreateSocket | ( | int | af, | |
int | type, | |||
const std::string & | protocol = "" | |||
) |
Create a socket file descriptor.
af | Address family AF_INET / AF_INET6 / ... | |
type | SOCK_STREAM / SOCK_DGRAM / ... | |
protocol | "tcp" / "udp" / ... |
Definition at line 286 of file Socket.cpp.
References closesocket, Errno, Handler(), INVALID_SOCKET, LOG_LEVEL_FATAL, ISocketHandler::LogError(), m_opt_keepalive, m_opt_reuse, m_socket_protocol, m_socket_type, OnOptions(), SetCloseAndDelete(), and StrError.
Referenced by UdpSocket::Bind(), SctpSocket::Bind(), UdpSocket::CreateConnection(), UdpSocket::Open(), TcpSocket::Open(), SctpSocket::Open(), and UdpSocket::SendToBuf().
00287 { 00288 struct protoent *p = NULL; 00289 int optval; 00290 SOCKET s; 00291 00292 #ifdef ENABLE_POOL 00293 m_socket_type = type; 00294 m_socket_protocol = protocol; 00295 #endif 00296 if (protocol.size()) 00297 { 00298 p = getprotobyname( protocol.c_str() ); 00299 if (!p) 00300 { 00301 Handler().LogError(this, "getprotobyname", Errno, StrError(Errno), LOG_LEVEL_FATAL); 00302 SetCloseAndDelete(); 00303 return INVALID_SOCKET; 00304 } 00305 } 00306 int protno = p ? p -> p_proto : 0; 00307 00308 s = socket(af, type, protno); 00309 if (s == INVALID_SOCKET) 00310 { 00311 Handler().LogError(this, "socket", Errno, StrError(Errno), LOG_LEVEL_FATAL); 00312 SetCloseAndDelete(); 00313 return INVALID_SOCKET; 00314 } 00315 OnOptions(af, type, protno, s); 00316 #ifdef SO_NOSIGPIPE 00317 { 00318 optval = 1; 00319 if (setsockopt(s, SOL_SOCKET, SO_NOSIGPIPE, (char *)&optval, sizeof(optval)) == -1) 00320 { 00321 Handler().LogError(this, "setsockopt(SOL_SOCKET, SO_NOSIGPIPE)", Errno, StrError(Errno), LOG_LEVEL_FATAL); 00322 closesocket(s); 00323 SetCloseAndDelete(); 00324 return INVALID_SOCKET; 00325 } 00326 } 00327 #endif 00328 if (type == SOCK_STREAM) 00329 { 00330 optval = m_opt_reuse ? 1 : 0; 00331 if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *)&optval, sizeof(optval)) == -1) 00332 { 00333 Handler().LogError(this, "setsockopt(SOL_SOCKET, SO_REUSEADDR)", Errno, StrError(Errno), LOG_LEVEL_FATAL); 00334 closesocket(s); 00335 SetCloseAndDelete(); 00336 return INVALID_SOCKET; 00337 } 00338 00339 optval = m_opt_keepalive ? 1 : 0; 00340 if (setsockopt(s, SOL_SOCKET, SO_KEEPALIVE, (char *)&optval, sizeof(optval)) == -1) 00341 { 00342 Handler().LogError(this, "setsockopt(SOL_SOCKET, SO_KEEPALIVE)", Errno, StrError(Errno), LOG_LEVEL_FATAL); 00343 closesocket(s); 00344 SetCloseAndDelete(); 00345 return INVALID_SOCKET; 00346 } 00347 } 00348 return s; 00349 }
void Socket::Set | ( | bool | bRead, | |
bool | bWrite, | |||
bool | bException = true | |||
) |
Add file descriptor to sockethandler fd_set's.
Definition at line 583 of file Socket.cpp.
References Handler(), m_socket, and ISocketHandler::Set().
Referenced by CheckConnect(), Close(), and TcpSocket::OnWrite().
bool Socket::Ready | ( | ) |
Returns true when socket file descriptor is valid, socket connection is established, and socket is not about to be closed.
Definition at line 595 of file Socket.cpp.
References CloseAndDelete(), Connecting(), INVALID_SOCKET, and m_socket.
Referenced by TcpSocket::OnRead(), and TcpSocket::SendBuf().
00596 { 00597 if (m_socket != INVALID_SOCKET && !Connecting() && !CloseAndDelete()) 00598 return true; 00599 return false; 00600 }
void Socket::OnRead | ( | ) | [virtual] |
Called when there is something to be read from the file descriptor.
Reimplemented in ISocketHandler::PoolSocket, ListenSocket< X >, SctpSocket, TcpSocket, and UdpSocket.
Definition at line 140 of file Socket.cpp.
void Socket::OnWrite | ( | ) | [virtual] |
Called when there is room for another write on the file descriptor.
Reimplemented in SctpSocket, and TcpSocket.
Definition at line 145 of file Socket.cpp.
void Socket::OnException | ( | ) | [virtual] |
Called on socket exception.
Definition at line 150 of file Socket.cpp.
References Connecting(), GetConnectionRetries(), GetConnectionRetry(), Handler(), LOG_LEVEL_FATAL, ISocketHandler::LogError(), m_socket, OnConnectFailed(), OnSocks4ConnectFailed(), SetCloseAndDelete(), SetConnecting(), Socks4(), and StrError.
00151 { 00152 #ifdef _WIN32 00153 if (Connecting()) 00154 { 00155 #ifdef ENABLE_SOCKS4 00156 if (Socks4()) 00157 OnSocks4ConnectFailed(); 00158 else 00159 #endif 00160 if (GetConnectionRetry() == -1 || 00161 (GetConnectionRetry() && 00162 GetConnectionRetries() < GetConnectionRetry() )) 00163 { 00164 // even though the connection failed at once, only retry after 00165 // the connection timeout 00166 // should we even try to connect again, when CheckConnect returns 00167 // false it's because of a connection error - not a timeout... 00168 } 00169 else 00170 { 00171 SetConnecting(false); // tnx snibbe 00172 SetCloseAndDelete(); 00173 OnConnectFailed(); 00174 } 00175 return; 00176 } 00177 #endif 00178 // errno valid here? 00179 int err; 00180 socklen_t errlen = sizeof(err); 00181 #ifdef _WIN32 00182 getsockopt(m_socket, SOL_SOCKET, SO_ERROR, (char *)&err, &errlen); 00183 #else 00184 getsockopt(m_socket, SOL_SOCKET, SO_ERROR, &err, &errlen); 00185 #endif 00186 Handler().LogError(this, "exception on select", err, StrError(err), LOG_LEVEL_FATAL); 00187 SetCloseAndDelete(); 00188 }
void Socket::OnDelete | ( | ) | [virtual] |
Called before a socket class is deleted by the ISocketHandler.
Reimplemented in HttpClientSocket, MinionSocket, and ResolvSocket.
Definition at line 191 of file Socket.cpp.
void Socket::OnConnect | ( | ) | [virtual] |
Called when a connection has completed.
Reimplemented in HttpGetSocket, HttpPostSocket, HttpPutSocket, MinderSocket, MinionSocket, and ResolvSocket.
Definition at line 196 of file Socket.cpp.
Referenced by TcpSocket::OnSocks4Read(), and TcpSocket::SSLNegotiate().
void Socket::OnAccept | ( | ) | [virtual] |
Called when an incoming connection has been completed.
Reimplemented in MinionSocket, ResolvSocket, and SmtpdSocket.
Definition at line 231 of file Socket.cpp.
Referenced by TcpSocket::SSLNegotiate().
void Socket::OnLine | ( | const std::string & | ) | [virtual] |
Called when a complete line has been read and the socket is in line protocol mode.
Reimplemented in HTTPSocket, MinderSocket, MinionSocket, ResolvSocket, SmtpdSocket, and TcpSocket.
Definition at line 603 of file Socket.cpp.
void Socket::OnConnectFailed | ( | ) | [virtual] |
Called on connect timeout (5s).
Definition at line 620 of file Socket.cpp.
Referenced by OnException(), TcpSocket::OnSocks4ConnectFailed(), TcpSocket::OnSocks4Read(), TcpSocket::OnWrite(), and SctpSocket::OnWrite().
virtual void Socket::OnOptions | ( | int | family, | |
int | type, | |||
int | protocol, | |||
SOCKET | ||||
) | [pure virtual] |
Called when a socket is created, to set socket options.
Implemented in ISocketHandler::PoolSocket, ListenSocket< X >, SctpSocket, TcpSocket, and UdpSocket.
Referenced by CreateSocket().
bool Socket::OnConnectRetry | ( | ) | [virtual] |
Connection retry callback - return false to abort connection attempts.
Definition at line 655 of file Socket.cpp.
void Socket::OnReconnect | ( | ) | [virtual] |
a reconnect has been made
Definition at line 662 of file Socket.cpp.
Referenced by TcpSocket::SSLNegotiate().
void Socket::OnDisconnect | ( | ) | [virtual] |
When a socket is set to reconnect, and a disconnect has been detected.
Definition at line 815 of file Socket.cpp.
bool Socket::CheckConnect | ( | ) | [virtual] |
Check whether a connection has been established.
Definition at line 201 of file Socket.cpp.
References Handler(), IsDisableRead(), LOG_LEVEL_FATAL, ISocketHandler::LogError(), m_socket, Set(), SetConnecting(), and StrError.
Referenced by TcpSocket::OnWrite(), and SctpSocket::OnWrite().
00202 { 00203 int err; 00204 socklen_t errlen = sizeof(err); 00205 bool r = true; 00206 #ifdef _WIN32 00207 getsockopt(m_socket, SOL_SOCKET, SO_ERROR, (char *)&err, &errlen); 00208 #else 00209 getsockopt(m_socket, SOL_SOCKET, SO_ERROR, &err, &errlen); 00210 #endif 00211 if (err) 00212 { 00213 Handler().LogError(this, "connect failed", err, StrError(err), LOG_LEVEL_FATAL); 00214 r = false; 00215 } 00216 // don't reset connecting flag on error here, we want the OnConnectFailed timeout later on 00218 if (r) // ok 00219 { 00220 Set(!IsDisableRead(), false); 00221 SetConnecting(false); 00222 } 00223 else 00224 { 00225 Set(false, false); // no more monitoring because connection failed 00226 } 00227 return r; 00228 }
void Socket::SetLineProtocol | ( | bool | = true |
) | [virtual] |
Enable the OnLine callback.
Do not create your own OnRead callback when using this.
Reimplemented in TcpSocket.
Definition at line 608 of file Socket.cpp.
References m_line_protocol.
Referenced by TcpSocket::SetLineProtocol().
00609 { 00610 m_line_protocol = x; 00611 }
bool Socket::LineProtocol | ( | ) |
Check line protocol mode.
Definition at line 614 of file Socket.cpp.
References m_line_protocol.
Referenced by TcpSocket::OnRead().
00615 { 00616 return m_line_protocol; 00617 }
void Socket::SetDeleteByHandler | ( | bool | = true |
) |
Set delete by handler true when you want the sockethandler to delete the socket instance after use.
Definition at line 364 of file Socket.cpp.
References m_bDel.
Referenced by MinderSocket::OnLine(), and SctpSocket::PeelOff().
00365 { 00366 m_bDel = x; 00367 }
bool Socket::DeleteByHandler | ( | ) |
Check delete by handler flag.
Definition at line 370 of file Socket.cpp.
References m_bDel.
Referenced by Detach().
00371 { 00372 return m_bDel; 00373 }
void Socket::SetCloseAndDelete | ( | bool | = true |
) |
Set close and delete to terminate the connection.
Definition at line 376 of file Socket.cpp.
References ISocketHandler::AddList(), Handler(), LIST_CLOSE, m_bClose, m_socket, and m_tClose.
Referenced by HttpPostSocket::AddFile(), UdpSocket::Bind(), CreateSocket(), HttpGetSocket::HttpGetSocket(), TcpSocket::InitSSLServer(), HttpDebugSocket::OnData(), HttpClientSocket::OnData(), ResolvSocket::OnDetached(), OnException(), HttpClientSocket::OnFirst(), HttpDebugSocket::OnHeaderComplete(), SmtpdSocket::OnLine(), ResolvSocket::OnLine(), MinionSocket::OnLine(), MinderSocket::OnLine(), TcpSocket::OnRead(), SctpSocket::OnRead(), TcpSocket::OnResolved(), TcpSocket::OnSocks4ConnectFailed(), TcpSocket::OnSocks4Read(), TcpSocket::OnSSLAccept(), TcpSocket::OnSSLConnect(), MinionSocket::OnVerifiedLine(), TcpSocket::OnWrite(), SctpSocket::OnWrite(), UdpSocket::Open(), TcpSocket::Open(), MinderSocket::SendHello(), HttpPutSocket::SetFile(), and TcpSocket::SSLNegotiate().
00377 { 00378 if (x != m_bClose) 00379 { 00380 Handler().AddList(m_socket, LIST_CLOSE, x); 00381 m_bClose = x; 00382 if (x) 00383 { 00384 m_tClose = time(NULL); 00385 } 00386 } 00387 }
bool Socket::CloseAndDelete | ( | ) |
Check close and delete flag.
Definition at line 390 of file Socket.cpp.
References m_bClose.
Referenced by TcpSocket::OnRead(), Ready(), and TcpSocket::SendBuf().
00391 { 00392 return m_bClose; 00393 }
void Socket::SetConnecting | ( | bool | = true |
) |
Socket should call CheckConnect on next write event from select().
Definition at line 396 of file Socket.cpp.
References ISocketHandler::AddList(), Handler(), LIST_CONNECTING, m_bConnecting, m_socket, and m_tConnect.
Referenced by SctpSocket::AddConnection(), CheckConnect(), OnException(), TcpSocket::OnSocks4ConnectFailed(), TcpSocket::OnSocks4Read(), TcpSocket::OnWrite(), SctpSocket::OnWrite(), TcpSocket::Open(), and SctpSocket::Open().
00397 { 00398 if (x != m_bConnecting) 00399 { 00400 Handler().AddList(m_socket, LIST_CONNECTING, x); 00401 m_bConnecting = x; 00402 if (x) 00403 { 00404 m_tConnect = time(NULL); 00405 } 00406 } 00407 }
bool Socket::Connecting | ( | ) |
Check connecting flag.
Definition at line 410 of file Socket.cpp.
References m_bConnecting.
Referenced by HttpGetSocket::HttpGetSocket(), OnException(), MinderSocket::OnLine(), TcpSocket::OnWrite(), SctpSocket::OnWrite(), Ready(), and TcpSocket::SendBuf().
00411 { 00412 return m_bConnecting; 00413 }
time_t Socket::GetConnectTime | ( | ) |
Number of seconds the socket has been connected.
Definition at line 589 of file Socket.cpp.
References m_tConnect.
00590 { 00591 return time(NULL) - m_tConnect; 00592 }
void Socket::SetRemoteAddress | ( | SocketAddress & | ) |
Used by ListenSocket.
ipv4 and ipv6
Definition at line 416 of file Socket.cpp.
References SocketAddress::GetCopy(), and m_remote_address.
Referenced by CopyConnection(), and TcpSocket::Open().
00417 { 00418 m_remote_address = ad.GetCopy(); 00419 }
std::auto_ptr< SocketAddress > Socket::GetRemoteSocketAddress | ( | ) |
Returns address of remote end.
Definition at line 422 of file Socket.cpp.
References m_remote_address.
Referenced by CopyConnection().
00423 { 00424 return std::auto_ptr<SocketAddress>(m_remote_address -> GetCopy()); 00425 }
ipaddr_t Socket::GetRemoteIP4 | ( | ) |
Returns address of remote end: ipv4.
Definition at line 444 of file Socket.cpp.
References Handler(), LOG_LEVEL_WARNING, ISocketHandler::LogError(), and m_remote_address.
00445 { 00446 ipaddr_t l = 0; 00447 #ifdef ENABLE_IPV6 00448 if (m_ipv6) 00449 { 00450 Handler().LogError(this, "GetRemoteIP4", 0, "get ipv4 address for ipv6 socket", LOG_LEVEL_WARNING); 00451 } 00452 #endif 00453 if (m_remote_address.get() != NULL) 00454 { 00455 struct sockaddr *p = *m_remote_address; 00456 struct sockaddr_in *sa = (struct sockaddr_in *)p; 00457 memcpy(&l, &sa -> sin_addr, sizeof(struct in_addr)); 00458 } 00459 return l; 00460 }
port_t Socket::GetRemotePort | ( | ) |
Returns remote port number: ipv4 and ipv6.
Definition at line 487 of file Socket.cpp.
References GetPort(), and m_remote_address.
00488 { 00489 if (!m_remote_address.get()) 00490 { 00491 return 0; 00492 } 00493 return m_remote_address -> GetPort(); 00494 }
std::string Socket::GetRemoteAddress | ( | ) |
Returns remote ip as string? ipv4 and ipv6.
Definition at line 497 of file Socket.cpp.
References m_remote_address.
Referenced by MinionSocket::OnAccept().
00498 { 00499 if (!m_remote_address.get()) 00500 { 00501 return ""; 00502 } 00503 return m_remote_address -> Convert(false); 00504 }
std::string Socket::GetRemoteHostname | ( | ) |
ipv4 and ipv6(not implemented)
Definition at line 507 of file Socket.cpp.
References m_remote_address.
00508 { 00509 if (!m_remote_address.get()) 00510 { 00511 return ""; 00512 } 00513 return m_remote_address -> Reverse(); 00514 }
ISocketHandler & Socket::Handler | ( | ) | const |
Returns reference to sockethandler that owns the socket.
If the socket is detached, this is a reference to the slave sockethandler.
Definition at line 428 of file Socket.cpp.
References IsDetached(), m_handler, and m_slave_handler.
Referenced by SctpSocket::AddAddress(), SctpSocket::AddConnection(), HttpPostSocket::AddFile(), UdpSocket::AddMulticastMembership(), UdpSocket::Bind(), SctpSocket::Bind(), CheckConnect(), Close(), CreateSocket(), HttpdSocket::datetime2httpdate(), UdpSocket::DropMulticastMembership(), GetClientRemoteAddress(), SctpSocket::getladdrs(), UdpSocket::GetMulticastTTL(), SctpSocket::getpaddrs(), GetPort(), GetRemoteIP4(), TcpSocket::GetSsl(), TcpSocket::GetSslContext(), HttpGetSocket::HttpGetSocket(), HttpDebugSocket::Init(), TcpSocket::InitializeContext(), TcpSocket::InitSSLServer(), UdpSocket::IsBroadcast(), UdpSocket::IsMulticastLoop(), HttpClientSocket::OnData(), ResolvSocket::OnDelete(), ResolvSocket::OnDetached(), OnException(), HttpClientSocket::OnFirst(), ResolvSocket::OnLine(), MinionSocket::OnLine(), MinderSocket::OnLine(), UdpSocket::OnRead(), TcpSocket::OnRead(), SctpSocket::OnRead(), TcpSocket::OnResolved(), OnSocks4Connect(), TcpSocket::OnSocks4ConnectFailed(), OnSocks4ConnectFailed(), TcpSocket::OnSocks4Read(), OnSocks4Read(), MinionSocket::OnVerifiedLine(), TcpSocket::OnWrite(), UdpSocket::Open(), TcpSocket::Open(), SctpSocket::Open(), SctpSocket::PeelOff(), CircularBuffer::Read(), SctpSocket::RemoveAddress(), Resolve(), UdpSocket::SendBuf(), TcpSocket::SendBuf(), MinionSocket::SendConnectList(), MinionSocket::SendHello(), MinderSocket::SendHello(), UdpSocket::SendToBuf(), Set(), UdpSocket::SetBroadcast(), SetCallOnConnect(), SetClientRemoteAddress(), SetCloseAndDelete(), SetConnecting(), SetDetach(), HttpPutSocket::SetFile(), UdpSocket::SetMulticastLoop(), UdpSocket::SetMulticastTTL(), SetNonblocking(), SetRetryClientConnect(), TcpSocket::SSLNegotiate(), HTTPSocket::url_this(), CircularBuffer::Write(), ~Socket(), and TcpSocket::~TcpSocket().
00429 { 00430 #ifdef ENABLE_DETACH 00431 if (IsDetached()) 00432 return *m_slave_handler; 00433 #endif 00434 return m_handler; 00435 }
ISocketHandler & Socket::MasterHandler | ( | ) | const |
Returns reference to sockethandler that owns the socket.
This one always returns the reference to the original sockethandler, even if the socket is detached.
Definition at line 438 of file Socket.cpp.
References m_handler.
00439 { 00440 return m_handler; 00441 }
bool Socket::SetNonblocking | ( | bool | ) |
Set socket non-block operation.
Definition at line 517 of file Socket.cpp.
References Errno, Handler(), LOG_LEVEL_ERROR, ISocketHandler::LogError(), m_socket, and StrError.
Referenced by UdpSocket::Bind(), Close(), UdpSocket::CreateConnection(), TcpSocket::OnSSLAccept(), TcpSocket::OnSSLConnect(), UdpSocket::Open(), TcpSocket::Open(), SctpSocket::Open(), UdpSocket::SendToBuf(), and TcpSocket::SSLNegotiate().
00518 { 00519 #ifdef _WIN32 00520 unsigned long l = bNb ? 1 : 0; 00521 int n = ioctlsocket(m_socket, FIONBIO, &l); 00522 if (n != 0) 00523 { 00524 Handler().LogError(this, "ioctlsocket(FIONBIO)", Errno, ""); 00525 return false; 00526 } 00527 return true; 00528 #else 00529 if (bNb) 00530 { 00531 if (fcntl(m_socket, F_SETFL, O_NONBLOCK) == -1) 00532 { 00533 Handler().LogError(this, "fcntl(F_SETFL, O_NONBLOCK)", Errno, StrError(Errno), LOG_LEVEL_ERROR); 00534 return false; 00535 } 00536 } 00537 else 00538 { 00539 if (fcntl(m_socket, F_SETFL, 0) == -1) 00540 { 00541 Handler().LogError(this, "fcntl(F_SETFL, 0)", Errno, StrError(Errno), LOG_LEVEL_ERROR); 00542 return false; 00543 } 00544 } 00545 return true; 00546 #endif 00547 }
bool Socket::SetNonblocking | ( | bool | , | |
SOCKET | ||||
) |
Set socket non-block operation.
Definition at line 550 of file Socket.cpp.
References Errno, Handler(), LOG_LEVEL_ERROR, ISocketHandler::LogError(), and StrError.
00551 { 00552 #ifdef _WIN32 00553 unsigned long l = bNb ? 1 : 0; 00554 int n = ioctlsocket(s, FIONBIO, &l); 00555 if (n != 0) 00556 { 00557 Handler().LogError(this, "ioctlsocket(FIONBIO)", Errno, ""); 00558 return false; 00559 } 00560 return true; 00561 #else 00562 if (bNb) 00563 { 00564 if (fcntl(s, F_SETFL, O_NONBLOCK) == -1) 00565 { 00566 Handler().LogError(this, "fcntl(F_SETFL, O_NONBLOCK)", Errno, StrError(Errno), LOG_LEVEL_ERROR); 00567 return false; 00568 } 00569 } 00570 else 00571 { 00572 if (fcntl(s, F_SETFL, 0) == -1) 00573 { 00574 Handler().LogError(this, "fcntl(F_SETFL, 0)", Errno, StrError(Errno), LOG_LEVEL_ERROR); 00575 return false; 00576 } 00577 } 00578 return true; 00579 #endif 00580 }
time_t Socket::Uptime | ( | ) |
Total lifetime of instance.
Definition at line 668 of file Socket.cpp.
References m_tCreate.
00669 { 00670 return time(NULL) - m_tCreate; 00671 }
Socket * Socket::GetParent | ( | ) |
Returns pointer to ListenSocket that created this instance on an incoming connection.
Definition at line 630 of file Socket.cpp.
References m_parent.
Referenced by HttpDebugSocket::Init().
00631 { 00632 return m_parent; 00633 }
void Socket::SetParent | ( | Socket * | ) |
Used by ListenSocket to set parent pointer of newly created socket instance.
Definition at line 636 of file Socket.cpp.
References m_parent.
00637 { 00638 m_parent = x; 00639 }
port_t Socket::GetPort | ( | ) | [virtual] |
Get listening port from ListenSocket<>.
Reimplemented in ListenSocket< X >, MinionSocket, and UdpSocket.
Definition at line 642 of file Socket.cpp.
References Handler(), LOG_LEVEL_WARNING, and ISocketHandler::LogError().
Referenced by GetRemotePort(), and HttpDebugSocket::Init().
00643 { 00644 Handler().LogError(this, "GetPort", 0, "GetPort only implemented for ListenSocket", LOG_LEVEL_WARNING); 00645 return 0; 00646 }
void Socket::SetClientRemoteAddress | ( | SocketAddress & | ) |
Set address/port of last connect() call.
Definition at line 851 of file Socket.cpp.
References SocketAddress::GetCopy(), Handler(), SocketAddress::IsValid(), LOG_LEVEL_ERROR, ISocketHandler::LogError(), and m_client_remote_address.
Referenced by CopyConnection(), and TcpSocket::Open().
00852 { 00853 if (!ad.IsValid()) 00854 { 00855 Handler().LogError(this, "SetClientRemoteAddress", 0, "remote address not valid", LOG_LEVEL_ERROR); 00856 } 00857 m_client_remote_address = ad.GetCopy(); 00858 }
std::auto_ptr< SocketAddress > Socket::GetClientRemoteAddress | ( | ) |
Get address/port of last connect() call.
Definition at line 861 of file Socket.cpp.
References Handler(), LOG_LEVEL_ERROR, ISocketHandler::LogError(), and m_client_remote_address.
Referenced by CopyConnection(), and TcpSocket::OnSocks4Connect().
00862 { 00863 if (!m_client_remote_address.get()) 00864 { 00865 Handler().LogError(this, "GetClientRemoteAddress", 0, "remote address not yet set", LOG_LEVEL_ERROR); 00866 } 00867 return std::auto_ptr<SocketAddress>(m_client_remote_address -> GetCopy()); 00868 }
void Socket::SetCallOnConnect | ( | bool | x = true |
) |
Instruct socket to call OnConnect callback next sockethandler cycle.
Definition at line 688 of file Socket.cpp.
References ISocketHandler::AddList(), Handler(), LIST_CALLONCONNECT, m_call_on_connect, and m_socket.
Referenced by TcpSocket::OnWrite(), SctpSocket::OnWrite(), and TcpSocket::Open().
00689 { 00690 Handler().AddList(m_socket, LIST_CALLONCONNECT, x); 00691 m_call_on_connect = x; 00692 }
bool Socket::CallOnConnect | ( | ) |
Check call on connect flag.
Definition at line 695 of file Socket.cpp.
References m_call_on_connect.
00696 { 00697 return m_call_on_connect; 00698 }
void Socket::SetReuse | ( | bool | x | ) |
Socket option SO_REUSEADDR.
Definition at line 701 of file Socket.cpp.
References m_opt_reuse.
Referenced by TcpSocket::OnOptions().
00702 { 00703 m_opt_reuse = x; 00704 }
void Socket::SetKeepalive | ( | bool | x | ) |
Socket option SO_KEEPALIVE.
Definition at line 707 of file Socket.cpp.
References m_opt_keepalive.
Referenced by TcpSocket::OnOptions().
00708 { 00709 m_opt_keepalive = x; 00710 }
void Socket::SetConnectTimeout | ( | int | x | ) |
Set timeout to use for connection attempt.
x | Timeout in seconds |
Definition at line 713 of file Socket.cpp.
References m_connect_timeout.
00714 { 00715 m_connect_timeout = x; 00716 }
int Socket::GetConnectTimeout | ( | ) |
Return number of seconds to wait for a connection.
Definition at line 719 of file Socket.cpp.
References m_connect_timeout.
00720 { 00721 return m_connect_timeout; 00722 }
void Socket::DisableRead | ( | bool | x = true |
) |
Ignore read events for an output only socket.
Definition at line 725 of file Socket.cpp.
References m_b_disable_read.
00726 { 00727 m_b_disable_read = x; 00728 }
bool Socket::IsDisableRead | ( | ) |
Check ignore read events flag.
Definition at line 731 of file Socket.cpp.
References m_b_disable_read.
Referenced by CheckConnect().
00732 { 00733 return m_b_disable_read; 00734 }
void Socket::SetRetryClientConnect | ( | bool | x = true |
) |
Set flag to initiate a connection attempt after a connection timeout.
Definition at line 737 of file Socket.cpp.
References ISocketHandler::AddList(), Handler(), LIST_RETRY, m_b_retry_connect, and m_socket.
Referenced by TcpSocket::OnSocks4ConnectFailed().
00738 { 00739 Handler().AddList(m_socket, LIST_RETRY, x); 00740 m_b_retry_connect = x; 00741 }
bool Socket::RetryClientConnect | ( | ) |
Check if a connection attempt should be made.
Definition at line 744 of file Socket.cpp.
References m_b_retry_connect.
00745 { 00746 return m_b_retry_connect; 00747 }
void Socket::SendBuf | ( | const char * | , | |
size_t | , | |||
int | = 0 | |||
) | [virtual] |
Common interface for SendBuf used by Tcp and Udp sockets.
Reimplemented in TcpSocket, and UdpSocket.
Definition at line 750 of file Socket.cpp.
void Socket::Send | ( | const std::string & | , | |
int | = 0 | |||
) | [virtual] |
Common interface for Send used by Tcp and Udp sockets.
Reimplemented in TcpSocket, and UdpSocket.
Definition at line 755 of file Socket.cpp.
void Socket::SetConnected | ( | bool | = true |
) |
Set connected status.
Definition at line 760 of file Socket.cpp.
References m_connected.
Referenced by UdpSocket::Open(), and TcpSocket::SSLNegotiate().
00761 { 00762 m_connected = x; 00763 }
bool Socket::IsConnected | ( | ) |
Check connected status.
Definition at line 766 of file Socket.cpp.
References m_connected.
Referenced by Close(), UdpSocket::SendBuf(), and TcpSocket::SendBuf().
00767 { 00768 return m_connected; 00769 }
void Socket::SetFlushBeforeClose | ( | bool | = true |
) |
Set flush before close to make a tcp socket completely empty its output buffer before closing the connection.
Definition at line 772 of file Socket.cpp.
References m_flush_before_close.
Referenced by TcpSocket::OnRead(), and TcpSocket::OnWrite().
00773 { 00774 m_flush_before_close = x; 00775 }
bool Socket::GetFlushBeforeClose | ( | ) |
Check flush before status.
Definition at line 778 of file Socket.cpp.
References m_flush_before_close.
00779 { 00780 return m_flush_before_close; 00781 }
void Socket::SetConnectionRetry | ( | int | n | ) |
Define number of connection retries (tcp only).
n = 0 - no retry n > 0 - number of retries n = -1 - unlimited retries
Definition at line 790 of file Socket.cpp.
References m_connection_retry.
00791 { 00792 m_connection_retry = x; 00793 }
int Socket::GetConnectionRetry | ( | ) |
Get number of maximum connection retries (tcp only).
Definition at line 784 of file Socket.cpp.
References m_connection_retry.
Referenced by OnException(), TcpSocket::OnWrite(), and SctpSocket::OnWrite().
00785 { 00786 return m_connection_retry; 00787 }
void Socket::IncreaseConnectionRetries | ( | ) |
Increase number of actual connection retries (tcp only).
Definition at line 802 of file Socket.cpp.
References m_retries.
00803 { 00804 m_retries++; 00805 }
int Socket::GetConnectionRetries | ( | ) |
Get number of actual connection retries (tcp only).
Definition at line 796 of file Socket.cpp.
References m_retries.
Referenced by OnException(), TcpSocket::OnWrite(), and SctpSocket::OnWrite().
00797 { 00798 return m_retries; 00799 }
void Socket::ResetConnectionRetries | ( | ) |
Reset actual connection retries (tcp only).
Definition at line 808 of file Socket.cpp.
References m_retries.
00809 { 00810 m_retries = 0; 00811 }
void Socket::SetErasedByHandler | ( | bool | x = true |
) |
Set flag indicating the socket is being actively deleted by the sockethandler.
Definition at line 821 of file Socket.cpp.
References m_b_erased_by_handler.
00822 { 00823 m_b_erased_by_handler = x; 00824 }
bool Socket::ErasedByHandler | ( | ) |
Get value of flag indicating socket is deleted by sockethandler.
Definition at line 827 of file Socket.cpp.
References m_b_erased_by_handler.
00828 { 00829 return m_b_erased_by_handler; 00830 }
time_t Socket::TimeSinceClose | ( | ) |
Return number of seconds since socket was ordered to close.
Definition at line 833 of file Socket.cpp.
References m_tClose.
00834 { 00835 return time(NULL) - m_tClose; 00836 }
void Socket::SetShutdown | ( | int | ) |
Set shutdown status.
Definition at line 839 of file Socket.cpp.
References m_shutdown.
Referenced by TcpSocket::OnRead().
00840 { 00841 m_shutdown = x; 00842 }
int Socket::GetShutdown | ( | ) |
Get shutdown status.
Definition at line 845 of file Socket.cpp.
References m_shutdown.
Referenced by Close().
00846 { 00847 return m_shutdown; 00848 }
uint64_t Socket::GetBytesSent | ( | bool | clear = false |
) | [virtual] |
uint64_t Socket::GetBytesReceived | ( | bool | clear = false |
) | [virtual] |
unsigned long int Socket::Random | ( | ) |
Definition at line 883 of file Socket.cpp.
References m_prng, and RandomNumber::next().
Referenced by HttpPostSocket::HttpPostSocket().
void Socket::OnSSLConnect | ( | ) | [virtual] |
SSL client/server support - internal use.
Reimplemented in TcpSocket.
Definition at line 890 of file Socket.cpp.
void Socket::OnSSLAccept | ( | ) | [virtual] |
SSL client/server support - internal use.
Reimplemented in TcpSocket.
Definition at line 895 of file Socket.cpp.
void Socket::OnSSLConnectFailed | ( | ) | [virtual] |
SSL negotiation failed for client connect.
Definition at line 942 of file Socket.cpp.
Referenced by TcpSocket::SSLNegotiate().
void Socket::OnSSLAcceptFailed | ( | ) | [virtual] |
SSL negotiation failed for server accept.
Definition at line 947 of file Socket.cpp.
Referenced by TcpSocket::SSLNegotiate().
bool Socket::SSLNegotiate | ( | ) | [virtual] |
bool Socket::IsSSL | ( | ) |
Check if SSL is Enabled for this TcpSocket.
Definition at line 906 of file Socket.cpp.
References m_b_enable_ssl.
Referenced by TcpSocket::Close(), TcpSocket::OnRead(), and TcpSocket::OnWrite().
00907 { 00908 return m_b_enable_ssl; 00909 }
void Socket::EnableSSL | ( | bool | x = true |
) |
Enable SSL operation for a TcpSocket.
Definition at line 912 of file Socket.cpp.
References m_b_enable_ssl.
Referenced by HttpDebugSocket::Init(), and HTTPSocket::url_this().
00913 { 00914 m_b_enable_ssl = x; 00915 }
bool Socket::IsSSLNegotiate | ( | ) |
Still negotiating ssl connection.
Definition at line 918 of file Socket.cpp.
References m_b_ssl.
00919 { 00920 return m_b_ssl; 00921 }
void Socket::SetSSLNegotiate | ( | bool | x = true |
) |
Set flag indicating ssl handshaking still in progress.
Definition at line 924 of file Socket.cpp.
References m_b_ssl.
Referenced by TcpSocket::OnSSLAccept(), TcpSocket::OnSSLConnect(), and TcpSocket::SSLNegotiate().
00925 { 00926 m_b_ssl = x; 00927 }
bool Socket::IsSSLServer | ( | ) |
OnAccept called with SSL Enabled.
Definition at line 930 of file Socket.cpp.
References m_b_ssl_server.
Referenced by TcpSocket::SSLNegotiate().
00931 { 00932 return m_b_ssl_server; 00933 }
void Socket::SetSSLServer | ( | bool | x = true |
) |
Set flag indicating that this is a TcpSocket with incoming SSL connection.
Definition at line 936 of file Socket.cpp.
References m_b_ssl_server.
Referenced by TcpSocket::OnSSLAccept().
00937 { 00938 m_b_ssl_server = x; 00939 }
virtual SSL_CTX* Socket::GetSslContext | ( | ) | [inline, virtual] |
virtual SSL* Socket::GetSsl | ( | ) | [inline, virtual] |
void Socket::SetIsClient | ( | ) |
Client = connecting TcpSocket.
Definition at line 968 of file Socket.cpp.
References m_bClient.
Referenced by TcpSocket::Open().
00969 { 00970 m_bClient = true; 00971 }
void Socket::SetSocketType | ( | int | x | ) |
Socket type from socket() call.
Definition at line 974 of file Socket.cpp.
References m_socket_type.
Referenced by CopyConnection().
00975 { 00976 m_socket_type = x; 00977 }
int Socket::GetSocketType | ( | ) |
Socket type from socket() call.
Definition at line 980 of file Socket.cpp.
References m_socket_type.
Referenced by CopyConnection().
00981 { 00982 return m_socket_type; 00983 }
void Socket::SetSocketProtocol | ( | const std::string & | x | ) |
Protocol type from socket() call.
Definition at line 986 of file Socket.cpp.
References m_socket_protocol.
Referenced by CopyConnection().
00987 { 00988 m_socket_protocol = x; 00989 }
const std::string & Socket::GetSocketProtocol | ( | ) |
Protocol type from socket() call.
Definition at line 992 of file Socket.cpp.
References m_socket_protocol.
Referenced by CopyConnection().
00993 { 00994 return m_socket_protocol; 00995 }
void Socket::SetRetain | ( | ) |
Instruct a client socket to stay open in the connection pool after use.
If you have connected to a server using tcp, you can call SetRetain to leave the connection open after your socket instance has been deleted. The next connection you make to the same server will reuse the already opened connection, if it is still available.
Definition at line 998 of file Socket.cpp.
References m_bClient, and m_bRetain.
Referenced by HTTPSocket::OnLine().
bool Socket::Retain | ( | ) |
Check retain flag.
Definition at line 1004 of file Socket.cpp.
References m_bRetain.
01005 { 01006 return m_bRetain; 01007 }
void Socket::SetLost | ( | ) |
Connection lost - error while reading/writing from a socket - TcpSocket only.
Definition at line 1010 of file Socket.cpp.
References m_bLost.
Referenced by TcpSocket::OnRead(), and TcpSocket::OnWrite().
01011 { 01012 m_bLost = true; 01013 }
bool Socket::Lost | ( | ) |
Check connection lost status flag, used by TcpSocket only.
Definition at line 1016 of file Socket.cpp.
References m_bLost.
01017 { 01018 return m_bLost; 01019 }
void Socket::CopyConnection | ( | Socket * | sock | ) |
Copy connection parameters from sock.
Definition at line 954 of file Socket.cpp.
References Attach(), GetClientRemoteAddress(), GetRemoteSocketAddress(), GetSocket(), GetSocketProtocol(), GetSocketType(), SetClientRemoteAddress(), SetRemoteAddress(), SetSocketProtocol(), and SetSocketType().
Referenced by TcpSocket::Open().
00955 { 00956 Attach( sock -> GetSocket() ); 00957 #ifdef ENABLE_IPV6 00958 SetIpv6( sock -> IsIpv6() ); 00959 #endif 00960 SetSocketType( sock -> GetSocketType() ); 00961 SetSocketProtocol( sock -> GetSocketProtocol() ); 00962 00963 SetClientRemoteAddress( *sock -> GetClientRemoteAddress() ); 00964 SetRemoteAddress( *sock -> GetRemoteSocketAddress() ); 00965 }
void Socket::OnSocks4Connect | ( | ) | [virtual] |
Socks4 client support internal use.
Reimplemented in TcpSocket.
Definition at line 1024 of file Socket.cpp.
References Handler(), and ISocketHandler::LogError().
void Socket::OnSocks4ConnectFailed | ( | ) | [virtual] |
Socks4 client support internal use.
Reimplemented in TcpSocket.
Definition at line 1030 of file Socket.cpp.
References Handler(), and ISocketHandler::LogError().
Referenced by OnException(), and SctpSocket::OnWrite().
01031 { 01032 Handler().LogError(this, "OnSocks4ConnectFailed", 0, "Use with TcpSocket only"); 01033 }
bool Socket::OnSocks4Read | ( | ) | [virtual] |
Socks4 client support internal use.
Reimplemented in TcpSocket.
Definition at line 1036 of file Socket.cpp.
References Handler(), and ISocketHandler::LogError().
01037 { 01038 Handler().LogError(this, "OnSocks4Read", 0, "Use with TcpSocket only"); 01039 return true; 01040 }
bool Socket::Socks4 | ( | ) |
socket still in socks4 negotiation mode
Definition at line 1049 of file Socket.cpp.
References m_bSocks4.
Referenced by OnException(), TcpSocket::OnRead(), TcpSocket::OnWrite(), SctpSocket::OnWrite(), and TcpSocket::Open().
01050 { 01051 return m_bSocks4; 01052 }
void Socket::SetSocks4 | ( | bool | x = true |
) |
Set flag indicating Socks4 handshaking in progress.
Definition at line 1055 of file Socket.cpp.
References m_bSocks4.
Referenced by TcpSocket::OnSocks4Read(), and TcpSocket::Open().
01056 { 01057 m_bSocks4 = x; 01058 }
void Socket::SetSocks4Host | ( | ipaddr_t | a | ) |
Set socks4 server host address to use.
Definition at line 1061 of file Socket.cpp.
References m_socks4_host.
01062 { 01063 m_socks4_host = a; 01064 }
void Socket::SetSocks4Host | ( | const std::string & | ) |
Set socks4 server hostname to use.
Definition at line 1043 of file Socket.cpp.
References m_socks4_host, and Utility::u2ip().
01044 { 01045 Utility::u2ip(host, m_socks4_host); 01046 }
void Socket::SetSocks4Port | ( | port_t | p | ) |
Socks4 server port to use.
Definition at line 1067 of file Socket.cpp.
References m_socks4_port.
01068 { 01069 m_socks4_port = p; 01070 }
void Socket::SetSocks4Userid | ( | const std::string & | x | ) |
Provide a socks4 userid if required by the socks4 server.
Definition at line 1073 of file Socket.cpp.
References m_socks4_userid.
01074 { 01075 m_socks4_userid = x; 01076 }
ipaddr_t Socket::GetSocks4Host | ( | ) |
Get the ip address of socks4 server to use.
Definition at line 1079 of file Socket.cpp.
References m_socks4_host.
Referenced by TcpSocket::Open().
01080 { 01081 return m_socks4_host; 01082 }
port_t Socket::GetSocks4Port | ( | ) |
Get the socks4 server port to use.
Definition at line 1085 of file Socket.cpp.
References m_socks4_port.
Referenced by TcpSocket::Open().
01086 { 01087 return m_socks4_port; 01088 }
const std::string & Socket::GetSocks4Userid | ( | ) |
Get socks4 userid.
Definition at line 1091 of file Socket.cpp.
References m_socks4_userid.
Referenced by TcpSocket::OnSocks4Connect().
01092 { 01093 return m_socks4_userid; 01094 }
int Socket::Resolve | ( | const std::string & | host, | |
port_t | port = 0 | |||
) |
Request an asynchronous dns resolution.
host | hostname to be resolved | |
port | port number passed along for the ride |
Definition at line 1199 of file Socket.cpp.
References Handler(), and ISocketHandler::Resolve().
Referenced by TcpSocket::Open().
Callback returning a resolved address.
id | Resolve ID from Resolve call | |
a | resolved ip address | |
port | port number passed to Resolve |
Reimplemented in TcpSocket.
Definition at line 1227 of file Socket.cpp.
int Socket::Resolve | ( | ipaddr_t | a | ) |
Request asynchronous reverse dns lookup.
a | in_addr to be translated |
Definition at line 1213 of file Socket.cpp.
References Handler(), and ISocketHandler::Resolve().
void Socket::OnReverseResolved | ( | int | id, | |
const std::string & | name | |||
) | [virtual] |
Callback returning reverse resolve results.
id | Resolve ID | |
name | Resolved hostname |
Definition at line 1239 of file Socket.cpp.
Referenced by ResolvSocket::OnLine().
void Socket::OnResolveFailed | ( | int | id | ) | [virtual] |
Callback indicating failed dns lookup.
id | Resolve ID |
Definition at line 1244 of file Socket.cpp.
Referenced by ResolvSocket::OnDelete(), and ResolvSocket::OnLine().
void Socket::OnDetached | ( | ) | [virtual] |
Callback fires when a new socket thread has started and this socket is ready for operation again.
Reimplemented in ResolvSocket.
Definition at line 1120 of file Socket.cpp.
Referenced by Socket::SocketThread::Run().
void Socket::SetDetach | ( | bool | x = true |
) |
Internal use.
Definition at line 1125 of file Socket.cpp.
References ISocketHandler::AddList(), Handler(), LIST_DETACH, m_detach, and m_socket.
Referenced by Detach().
01126 { 01127 Handler().AddList(m_socket, LIST_DETACH, x); 01128 m_detach = x; 01129 }
bool Socket::IsDetach | ( | ) |
Check detach flag.
Definition at line 1132 of file Socket.cpp.
References m_detach.
01133 { 01134 return m_detach; 01135 }
void Socket::SetDetached | ( | bool | x = true |
) |
Internal use.
Definition at line 1138 of file Socket.cpp.
References m_detached.
Referenced by DetachSocket().
01139 { 01140 m_detached = x; 01141 }
const bool Socket::IsDetached | ( | ) | const |
Check detached flag.
Definition at line 1144 of file Socket.cpp.
References m_detached.
Referenced by Handler().
01145 { 01146 return m_detached; 01147 }
bool Socket::Detach | ( | ) |
Order this socket to start its own thread and call OnDetached when ready for operation.
Definition at line 1099 of file Socket.cpp.
References DeleteByHandler(), m_detached, m_pThread, and SetDetach().
Referenced by ResolvSocket::OnLine().
01100 { 01101 if (!DeleteByHandler()) 01102 return false; 01103 if (m_pThread) 01104 return false; 01105 if (m_detached) 01106 return false; 01107 SetDetach(); 01108 return true; 01109 }
void Socket::SetSlaveHandler | ( | ISocketHandler * | ) |
Store the slave sockethandler pointer.
Definition at line 1150 of file Socket.cpp.
References m_slave_handler.
Referenced by Socket::SocketThread::Run().
01151 { 01152 m_slave_handler = p; 01153 }
void Socket::DetachSocket | ( | ) |
Create new thread for this socket to run detached in.
Definition at line 1112 of file Socket.cpp.
References m_pThread, and SetDetached().
01113 { 01114 SetDetached(); 01115 m_pThread = new SocketThread(this); 01116 m_pThread -> SetRelease(true); 01117 }
void Socket::SetTrafficMonitor | ( | IFile * | p | ) | [inline] |
IFile* Socket::GetTrafficMonitor | ( | ) | [inline, protected] |
Definition at line 478 of file Socket.h.
Referenced by TcpSocket::OnRead(), and TcpSocket::OnWrite().
00478 { return m_traffic_monitor; }
friend class ISocketHandler [friend] |
RandomNumber Socket::m_prng [protected] |
ISocketHandler& Socket::m_handler [private] |
Reference of ISocketHandler in control of this socket.
Definition at line 489 of file Socket.h.
Referenced by Handler(), and MasterHandler().
SOCKET Socket::m_socket [private] |
File descriptor.
Definition at line 490 of file Socket.h.
Referenced by Attach(), CheckConnect(), Close(), GetSocket(), OnException(), Ready(), Set(), SetCallOnConnect(), SetCloseAndDelete(), SetConnecting(), SetDetach(), SetNonblocking(), SetRetryClientConnect(), and ~Socket().
bool Socket::m_bDel [private] |
Delete by handler flag.
Definition at line 491 of file Socket.h.
Referenced by DeleteByHandler(), and SetDeleteByHandler().
bool Socket::m_bClose [private] |
Close and delete flag.
Definition at line 492 of file Socket.h.
Referenced by CloseAndDelete(), and SetCloseAndDelete().
bool Socket::m_bConnecting [private] |
Flag indicating connection in progress.
Definition at line 493 of file Socket.h.
Referenced by Connecting(), and SetConnecting().
time_t Socket::m_tConnect [private] |
Time in seconds when connection was established.
Definition at line 494 of file Socket.h.
Referenced by GetConnectTime(), and SetConnecting().
time_t Socket::m_tCreate [private] |
bool Socket::m_line_protocol [private] |
Line protocol mode flag.
Definition at line 496 of file Socket.h.
Referenced by LineProtocol(), and SetLineProtocol().
Socket* Socket::m_parent [private] |
Pointer to ListenSocket class, valid for incoming sockets.
Reimplemented in ResolvSocket.
Definition at line 502 of file Socket.h.
Referenced by GetParent(), and SetParent().
bool Socket::m_call_on_connect [private] |
OnConnect will be called next ISocketHandler cycle if true.
Definition at line 503 of file Socket.h.
Referenced by CallOnConnect(), and SetCallOnConnect().
bool Socket::m_opt_reuse [private] |
Socket option reuseaddr.
Definition at line 504 of file Socket.h.
Referenced by CreateSocket(), and SetReuse().
bool Socket::m_opt_keepalive [private] |
Socket option keep-alive.
Definition at line 505 of file Socket.h.
Referenced by CreateSocket(), and SetKeepalive().
int Socket::m_connect_timeout [private] |
Connection timeout (seconds).
Definition at line 506 of file Socket.h.
Referenced by GetConnectTimeout(), and SetConnectTimeout().
bool Socket::m_b_disable_read [private] |
Disable checking for read events.
Definition at line 507 of file Socket.h.
Referenced by DisableRead(), and IsDisableRead().
bool Socket::m_b_retry_connect [private] |
Try another connection attempt next ISocketHandler cycle.
Definition at line 508 of file Socket.h.
Referenced by RetryClientConnect(), and SetRetryClientConnect().
bool Socket::m_connected [private] |
Socket is connected (tcp/udp).
Definition at line 509 of file Socket.h.
Referenced by IsConnected(), and SetConnected().
bool Socket::m_flush_before_close [private] |
Send all data before closing (default true).
Definition at line 510 of file Socket.h.
Referenced by GetFlushBeforeClose(), and SetFlushBeforeClose().
int Socket::m_connection_retry [private] |
Maximum connection retries (tcp).
Definition at line 511 of file Socket.h.
Referenced by GetConnectionRetry(), and SetConnectionRetry().
int Socket::m_retries [private] |
Actual number of connection retries (tcp).
Definition at line 512 of file Socket.h.
Referenced by GetConnectionRetries(), IncreaseConnectionRetries(), and ResetConnectionRetries().
bool Socket::m_b_erased_by_handler [private] |
Set by handler before delete.
Definition at line 513 of file Socket.h.
Referenced by ErasedByHandler(), and SetErasedByHandler().
time_t Socket::m_tClose [private] |
Time in seconds when ordered to close.
Definition at line 514 of file Socket.h.
Referenced by SetCloseAndDelete(), and TimeSinceClose().
int Socket::m_shutdown [private] |
Shutdown status.
Definition at line 515 of file Socket.h.
Referenced by GetShutdown(), and SetShutdown().
std::auto_ptr<SocketAddress> Socket::m_client_remote_address [private] |
Address of last connect().
Definition at line 516 of file Socket.h.
Referenced by GetClientRemoteAddress(), and SetClientRemoteAddress().
std::auto_ptr<SocketAddress> Socket::m_remote_address [private] |
Remote end address.
Definition at line 517 of file Socket.h.
Referenced by GetRemoteAddress(), GetRemoteHostname(), GetRemoteIP4(), GetRemotePort(), GetRemoteSocketAddress(), and SetRemoteAddress().
IFile* Socket::m_traffic_monitor [private] |
bool Socket::m_b_enable_ssl [private] |
Enable SSL for this TcpSocket.
Definition at line 521 of file Socket.h.
Referenced by EnableSSL(), and IsSSL().
bool Socket::m_b_ssl [private] |
ssl negotiation mode (TcpSocket)
Definition at line 522 of file Socket.h.
Referenced by IsSSLNegotiate(), and SetSSLNegotiate().
bool Socket::m_b_ssl_server [private] |
True if this is an incoming ssl TcpSocket connection.
Definition at line 523 of file Socket.h.
Referenced by IsSSLServer(), and SetSSLServer().
int Socket::m_socket_type [private] |
Type of socket, from socket() call.
Definition at line 527 of file Socket.h.
Referenced by CreateSocket(), GetSocketType(), and SetSocketType().
std::string Socket::m_socket_protocol [private] |
Protocol, from socket() call.
Definition at line 528 of file Socket.h.
Referenced by CreateSocket(), GetSocketProtocol(), and SetSocketProtocol().
bool Socket::m_bClient [private] |
only client connections are pooled
Definition at line 529 of file Socket.h.
Referenced by SetIsClient(), and SetRetain().
bool Socket::m_bRetain [private] |
keep connection on close
Definition at line 530 of file Socket.h.
Referenced by Retain(), SetRetain(), and ~Socket().
bool Socket::m_bLost [private] |
bool Socket::m_bSocks4 [private] |
socks4 negotiation mode (TcpSocket)
Definition at line 535 of file Socket.h.
Referenced by SetSocks4(), and Socks4().
ipaddr_t Socket::m_socks4_host [private] |
socks4 server address
Definition at line 536 of file Socket.h.
Referenced by GetSocks4Host(), and SetSocks4Host().
port_t Socket::m_socks4_port [private] |
socks4 server port number
Definition at line 537 of file Socket.h.
Referenced by GetSocks4Port(), and SetSocks4Port().
std::string Socket::m_socks4_userid [private] |
socks4 server usedid
Definition at line 538 of file Socket.h.
Referenced by GetSocks4Userid(), and SetSocks4Userid().
bool Socket::m_detach [private] |
Socket ordered to detach flag.
Definition at line 542 of file Socket.h.
Referenced by IsDetach(), and SetDetach().
bool Socket::m_detached [private] |
Socket has been detached.
Definition at line 543 of file Socket.h.
Referenced by Detach(), IsDetached(), and SetDetached().
SocketThread* Socket::m_pThread [private] |
Detach socket thread class pointer.
Definition at line 544 of file Socket.h.
Referenced by Detach(), and DetachSocket().
ISocketHandler* Socket::m_slave_handler [private] |
Actual sockethandler while detached.
Definition at line 545 of file Socket.h.
Referenced by Handler(), and SetSlaveHandler().