"Helper" class for creating TCP connections in a non-blocking manner More...
#include <tcp.h>
Public Member Functions | |
TCPConnecter (const NetworkAddress &address) | |
Create a new connecter for the given address. | |
virtual | ~TCPConnecter () |
Silence the warnings. | |
virtual void | OnConnect (SOCKET s) |
Callback when the connection succeeded. | |
virtual void | OnFailure () |
Callback for when the connection attempt failed. | |
Static Public Member Functions | |
static void | CheckCallbacks () |
Check whether we need to call the callback, i.e. | |
static void | KillAll () |
Kill all connection attempts. | |
Protected Attributes | |
NetworkAddress | address |
Address we're connecting to. | |
Private Member Functions | |
void | Connect () |
The actual connection function. | |
Static Private Member Functions | |
static void | ThreadEntry (void *param) |
Entry point for the new threads. | |
Private Attributes | |
class ThreadObject * | thread |
Thread used to create the TCP connection. | |
bool | connected |
Whether we succeeded in making the connection. | |
bool | aborted |
Whether we bailed out (i.e. connection making failed). | |
bool | killed |
Whether we got killed. | |
SOCKET | sock |
The socket we're connecting with. |
"Helper" class for creating TCP connections in a non-blocking manner
Definition at line 53 of file tcp.h.
TCPConnecter::TCPConnecter | ( | const NetworkAddress & | address | ) |
Create a new connecter for the given address.
address | the (un)resolved address to connect to |
Definition at line 28 of file tcp_connect.cpp.
References SmallVector< T, S >::Append(), Connect(), ThreadObject::New(), thread, and ThreadEntry().
void TCPConnecter::CheckCallbacks | ( | ) | [static] |
Check whether we need to call the callback, i.e.
whether we have connected or aborted and call the appropriate callback for that. It's done this way to ease on the locking that would otherwise be needed everywhere.
Definition at line 67 of file tcp_connect.cpp.
References aborted, SmallVector< T, S >::Begin(), connected, SmallVector< T, S >::End(), SmallVector< T, S >::Erase(), killed, OnConnect(), OnFailure(), and sock.
void TCPConnecter::KillAll | ( | ) | [static] |
Kill all connection attempts.
Definition at line 94 of file tcp_connect.cpp.
References SmallVector< T, S >::Begin(), and SmallVector< T, S >::End().
Referenced by NetworkClose().
virtual void TCPConnecter::OnConnect | ( | SOCKET | s | ) | [inline, virtual] |
Callback when the connection succeeded.
s | the socket that we opened |
Reimplemented in NetworkHTTPContentConnecter, TCPQueryConnecter, TCPClientConnecter, and NetworkContentConnecter.
Definition at line 78 of file tcp.h.
Referenced by CheckCallbacks().
void TCPConnecter::ThreadEntry | ( | void * | param | ) | [static, private] |
Entry point for the new threads.
param | the TCPConnecter instance to call Connect on. |
Definition at line 56 of file tcp_connect.cpp.
References Connect().
Referenced by TCPConnecter().