IXWebSocket/ixwebsocket/IXSocketAppleSSL.h

41 lines
1.0 KiB
C
Raw Normal View History

2018-09-27 23:56:48 +02:00
/*
* IXSocketAppleSSL.h
* Author: Benjamin Sergeant
* Copyright (c) 2017-2018 Machine Zone, Inc. All rights reserved.
*/
#pragma once
#include "IXSocket.h"
2018-12-15 01:28:11 +01:00
#include "IXCancellationRequest.h"
2018-09-27 23:56:48 +02:00
#include <Security/Security.h>
#include <Security/SecureTransport.h>
#include <mutex>
namespace ix
{
class SocketAppleSSL : public Socket
{
public:
2018-12-30 06:53:33 +01:00
SocketAppleSSL(int fd = -1);
2018-09-27 23:56:48 +02:00
~SocketAppleSSL();
virtual bool connect(const std::string& host,
int port,
std::string& errMsg,
2018-12-15 01:28:11 +01:00
const CancellationRequest& isCancellationRequested) final;
2018-09-27 23:56:48 +02:00
virtual void close() final;
virtual ssize_t send(char* buffer, size_t length) final;
virtual ssize_t send(const std::string& buffer) final;
virtual ssize_t recv(void* buffer, size_t length) final;
2018-09-27 23:56:48 +02:00
private:
SSLContextRef _sslContext;
mutable std::mutex _mutex; // AppleSSL routines are not thread-safe
};
}