Go to the documentation of this file.
12 #include "../../stdafx.h"
13 #include "../../thread.h"
17 #include "../../safeguards.h"
43 if (this->
sock == INVALID_SOCKET) {
73 if (cur->
sock != INVALID_SOCKET) closesocket(cur->
sock);
static void CheckCallbacks()
Check whether we need to call the callback, i.e.
TCPConnecter(const NetworkAddress &address)
Create a new connecter for the given address.
virtual void OnConnect(SOCKET s)
Callback when the connection succeeded.
SOCKET Connect()
Connect to the given address.
std::atomic< bool > aborted
Whether we bailed out (i.e. connection making failed)
"Helper" class for creating TCP connections in a non-blocking manner
static std::vector< TCPConnecter * > _tcp_connecters
List of connections that are currently being created.
bool StartNewThread(std::thread *thr, const char *name, TFn &&_Fx, TArgs &&... _Ax)
Start a new thread.
bool killed
Whether we got killed.
static void KillAll()
Kill all connection attempts.
NetworkAddress address
Address we're connecting to.
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...
std::atomic< bool > connected
Whether we succeeded in making the connection.
static void ThreadEntry(TCPConnecter *param)
Entry point for the new threads.
virtual void OnFailure()
Callback for when the connection attempt failed.
void Connect()
The actual connection function.