1 #pragma once
2 
3 #include "stdafx.h"
4 
5 class Socket
6 {
7 private:
8 #ifndef LIBRETRO
9 	#ifdef _WIN32
10 	bool _cleanupWSA = false;
11 	#endif
12 
13 	uintptr_t _socket = ~0;
14 	bool _connectionError = false;
15 	char* _sendBuffer;
16 	int _bufferPosition;
17 	int32_t _UPnPPort = -1;
18 #endif
19 
20 public:
21 	Socket();
22 	Socket(uintptr_t socket);
23 	~Socket();
24 
25 	void SetSocketOptions();
26 	void SetConnectionErrorFlag();
27 
28 	void Close();
29 	bool ConnectionError();
30 
31 	void Bind(uint16_t port);
32 	bool Connect(const char* hostname, uint16_t port);
33 	void Listen(int backlog);
34 	shared_ptr<Socket> Accept();
35 
36 	int Send(char *buf, int len, int flags);
37 	void BufferedSend(char *buf, int len);
38 	void SendBuffer();
39 	int Recv(char *buf, int len, int flags);
40 };
41