/* * IXSocketFactory.cpp * Author: Benjamin Sergeant * Copyright (c) 2019 Machine Zone, Inc. All rights reserved. */ #include "IXSocketFactory.h" #ifdef IXWEBSOCKET_USE_TLS #ifdef IXWEBSOCKET_USE_MBED_TLS #include #elif defined(_WIN32) #include #elif defined(IXWEBSOCKET_USE_OPEN_SSL) #include #elif __APPLE__ #include #endif #else #include #endif namespace ix { std::shared_ptr createSocket(bool tls, int fd, std::string& errorMsg, const SocketTLSOptions& tlsOptions) { errorMsg.clear(); std::shared_ptr socket; if (!tls) { socket = std::make_shared(fd); } else { #ifdef IXWEBSOCKET_USE_TLS #if defined(IXWEBSOCKET_USE_MBED_TLS) socket = std::make_shared(tlsOptions, fd); #elif defined(IXWEBSOCKET_USE_OPEN_SSL) socket = std::make_shared(tlsOptions, fd); #elif defined(_WIN32) socket = std::make_shared(tlsOptions, fd); #elif defined(__APPLE__) socket = std::make_shared(tlsOptions, fd); #endif #else errorMsg = "TLS support is not enabled on this platform."; return nullptr; #endif } if (!socket->init(errorMsg)) { socket.reset(); } return socket; } } // namespace ix