Windows support (no TLS yet)
This commit is contained in:
@ -11,6 +11,8 @@
|
||||
#include <mutex>
|
||||
#include <atomic>
|
||||
|
||||
struct addrinfo;
|
||||
|
||||
namespace ix
|
||||
{
|
||||
class Socket {
|
||||
@ -20,9 +22,9 @@ namespace ix
|
||||
Socket();
|
||||
virtual ~Socket();
|
||||
|
||||
static int hostname_connect(const std::string& hostname,
|
||||
int port,
|
||||
std::string& errMsg);
|
||||
int hostname_connect(const std::string& hostname,
|
||||
int port,
|
||||
std::string& errMsg);
|
||||
void configure();
|
||||
|
||||
virtual void poll(const OnPollCallback& onPollCallback);
|
||||
@ -38,13 +40,24 @@ namespace ix
|
||||
virtual int send(const std::string& buffer);
|
||||
virtual int recv(void* buffer, size_t length);
|
||||
|
||||
int getErrno() const;
|
||||
static bool init(); // Required on Windows to initialize WinSocket
|
||||
static void cleanup(); // Required on Windows to cleanup WinSocket
|
||||
|
||||
protected:
|
||||
void wakeUpFromPollApple();
|
||||
void wakeUpFromPollLinux();
|
||||
|
||||
void closeSocket(int fd);
|
||||
|
||||
std::atomic<int> _sockfd;
|
||||
int _eventfd;
|
||||
std::mutex _socketMutex;
|
||||
|
||||
private:
|
||||
bool connectToAddress(const struct addrinfo *address,
|
||||
int& sockfd,
|
||||
std::string& errMsg);
|
||||
};
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user