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