12 #include "../../stdafx.h" 13 #include "../../thread.h" 17 #include "../../safeguards.h" 43 if (this->
sock == INVALID_SOCKET) {
71 if (cur->
sock != INVALID_SOCKET) closesocket(cur->
sock);
NetworkAddress address
Address we're connecting to.
static void KillAll()
Kill all connection attempts.
"Helper" class for creating TCP connections in a non-blocking manner
bool aborted
Whether we bailed out (i.e. connection making failed)
SOCKET sock
The socket we're connecting with.
Wrapper for (un)resolved network addresses; there's no reason to transform a numeric IP to a string a...
TCPConnecter(const NetworkAddress &address)
Create a new connecter for the given address.
virtual void OnConnect(SOCKET s)
Callback when the connection succeeded.
virtual void OnFailure()
Callback for when the connection attempt failed.
bool StartNewThread(std::thread *thr, const char *name, TFn &&_Fx, TArgs &&... _Ax)
Start a new thread.
static void CheckCallbacks()
Check whether we need to call the callback, i.e.
static void ThreadEntry(TCPConnecter *param)
Entry point for the new threads.
bool killed
Whether we got killed.
SOCKET Connect()
Connect to the given address.
bool connected
Whether we succeeded in making the connection.
static std::vector< TCPConnecter * > _tcp_connecters
List of connections that are currently being created.
Basic functions to receive and send TCP packets.
void Connect()
The actual connection function.