add cancellation support while connecting, to speed up WebSocket::stop

This commit is contained in:
Benjamin Sergeant
2018-12-09 17:56:20 -08:00
parent 62528e6a0b
commit 8c079787f0
13 changed files with 69 additions and 25 deletions

View File

@ -7,20 +7,25 @@
#pragma once
#include <string>
#include <functional>
struct addrinfo;
namespace ix
{
using CancellationRequest = std::function<bool()>;
class SocketConnect {
public:
static int connect(const std::string& hostname,
int port,
std::string& errMsg);
std::string& errMsg,
CancellationRequest isCancellationRequested);
static bool connectToAddress(const struct addrinfo *address,
int& sockfd,
std::string& errMsg);
std::string& errMsg,
CancellationRequest isCancellationRequested);
static void configure(int sockfd);
};