2018-12-09 23:07:40 +01:00
|
|
|
/*
|
|
|
|
* IXSocketConnect.h
|
|
|
|
* Author: Benjamin Sergeant
|
|
|
|
* Copyright (c) 2018 Machine Zone, Inc. All rights reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2018-12-15 01:28:11 +01:00
|
|
|
#include "IXCancellationRequest.h"
|
|
|
|
|
2018-12-09 23:07:40 +01:00
|
|
|
#include <string>
|
|
|
|
|
|
|
|
struct addrinfo;
|
|
|
|
|
|
|
|
namespace ix
|
|
|
|
{
|
|
|
|
class SocketConnect {
|
|
|
|
public:
|
|
|
|
static int connect(const std::string& hostname,
|
|
|
|
int port,
|
2018-12-10 02:56:20 +01:00
|
|
|
std::string& errMsg,
|
2018-12-15 01:28:11 +01:00
|
|
|
const CancellationRequest& isCancellationRequested);
|
2018-12-09 23:07:40 +01:00
|
|
|
|
2018-12-15 01:28:11 +01:00
|
|
|
private:
|
2018-12-09 23:07:40 +01:00
|
|
|
static bool connectToAddress(const struct addrinfo *address,
|
|
|
|
int& sockfd,
|
2018-12-10 02:56:20 +01:00
|
|
|
std::string& errMsg,
|
2018-12-15 01:28:11 +01:00
|
|
|
const CancellationRequest& isCancellationRequested);
|
2018-12-09 23:07:40 +01:00
|
|
|
|
|
|
|
static void configure(int sockfd);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|