13 #ifdef SL_BUILD_WITH_OPENSSL
16 # include <winsock2.h>
17 # include <ws2tcpip.h>
19 # include <sys/socket.h>
20 # include <netinet/in.h>
21 # include <arpa/inet.h>
26 # include <openssl/ssl.h>
27 # include <openssl/err.h>
28 # include <functional>
35 # define SERVER_NOT_REACHABLE 1
36 # define CANT_CREATE_DIR 2
37 # define CANT_CREATE_FILE 3
38 # define CONNECTION_CLOSED 4
48 struct sockaddr_in sa;
49 struct sockaddr_in6 sa6;
54 static WSADATA wsadata;
55 static bool initialized;
58 static bool SocketEnable()
64 ret = WSAStartup(MAKEWORD(2, 2), &wsadata);
74 static void SocketDisable()
86 virtual ~Socket() =
default;
89 virtual int connectTo(
string ip,
int port);
90 virtual int sendData(
const char* data,
size_t size);
91 virtual int receive(
function<
int(
char* data,
int size)> dataCB,
int max = 0);
92 virtual void disconnect();
93 void interrupt() { _interrupt =
true; };
96 std::atomic_bool _interrupt{
false};
100 class SecureSocket :
public Socket
111 virtual int connectTo(
string ip,
int port);
112 virtual int sendData(
const char* data,
size_t size);
113 virtual int receive(
function<
int(
char* data,
int size)> dataCB,
int max = 0);
114 virtual void disconnect();
122 DNSRequest(
string host);
124 string getHostname();
135 vector<char> firstBytes;
147 size_t contentLength;
149 GetRequest(
string url,
string user =
"",
string pwd =
"");
156 int processHttpHeaders(vector<char>& data);
162 int getContent(
function<
int(
char* data,
int size)> contentCB);
165 vector<string> getListing();
182 int download(
string url,
183 function<
int(
string path,
string file,
size_t size)> processFile,
184 function<
int(
char* data,
int size)> writeChunk,
185 function<
int(
string)> processDir,
200 int download(
string url,
204 function<
int(
size_t curr,
size_t filesize)> progress =
nullptr);
207 int download(
string url,
209 function<
int(
size_t curr,
size_t filesize)> progress =
nullptr);
212 int length(
string url,
string user =
"",
string pwd =
"");
The SLScene class represents the top level instance holding the scene structure.