2014-07-06 19:54:47 -04:00
|
|
|
#pragma once
|
2015-07-11 10:01:06 -04:00
|
|
|
|
2014-07-06 19:54:47 -04:00
|
|
|
#include "stdafx.h"
|
|
|
|
|
|
|
|
class Socket
|
|
|
|
{
|
|
|
|
private:
|
2018-01-05 15:37:49 -05:00
|
|
|
#ifndef LIBRETRO
|
2018-01-05 15:03:33 -05:00
|
|
|
#ifdef _WIN32
|
2016-12-17 23:14:47 -05:00
|
|
|
bool _cleanupWSA = false;
|
|
|
|
#endif
|
|
|
|
|
2015-07-11 10:01:06 -04:00
|
|
|
uintptr_t _socket = ~0;
|
2014-07-06 19:54:47 -04:00
|
|
|
bool _connectionError = false;
|
|
|
|
char* _sendBuffer;
|
|
|
|
int _bufferPosition;
|
2014-07-07 18:43:50 -04:00
|
|
|
int32_t _UPnPPort = -1;
|
2018-01-05 15:37:49 -05:00
|
|
|
#endif
|
2014-07-06 19:54:47 -04:00
|
|
|
|
|
|
|
public:
|
2015-07-11 10:01:06 -04:00
|
|
|
Socket();
|
|
|
|
Socket(uintptr_t socket);
|
|
|
|
~Socket();
|
2014-07-06 19:54:47 -04:00
|
|
|
|
2015-07-11 10:01:06 -04:00
|
|
|
void SetSocketOptions();
|
|
|
|
void SetConnectionErrorFlag();
|
2014-07-06 19:54:47 -04:00
|
|
|
|
2015-07-11 10:01:06 -04:00
|
|
|
void Close();
|
|
|
|
bool ConnectionError();
|
2014-07-06 19:54:47 -04:00
|
|
|
|
2015-07-11 10:01:06 -04:00
|
|
|
void Bind(uint16_t port);
|
|
|
|
bool Connect(const char* hostname, uint16_t port);
|
|
|
|
void Listen(int backlog);
|
|
|
|
shared_ptr<Socket> Accept();
|
2014-07-07 23:38:29 -04:00
|
|
|
|
2015-07-11 10:01:06 -04:00
|
|
|
int Send(char *buf, int len, int flags);
|
|
|
|
void BufferedSend(char *buf, int len);
|
|
|
|
void SendBuffer();
|
|
|
|
int Recv(char *buf, int len, int flags);
|
2014-07-06 19:54:47 -04:00
|
|
|
};
|