2017-09-11 20:51:11 +00:00
|
|
|
#ifndef __TRACYSOCKET_HPP__
|
|
|
|
#define __TRACYSOCKET_HPP__
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
2017-09-12 23:53:47 +00:00
|
|
|
struct timeval;
|
|
|
|
|
2017-09-11 20:51:11 +00:00
|
|
|
namespace tracy
|
|
|
|
{
|
|
|
|
|
|
|
|
class Socket
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Socket();
|
|
|
|
Socket( int sock );
|
|
|
|
~Socket();
|
|
|
|
|
|
|
|
bool Connect( const char* addr, const char* port );
|
|
|
|
void Close();
|
|
|
|
|
|
|
|
int Send( const void* buf, int len );
|
2017-09-12 23:53:47 +00:00
|
|
|
int Recv( void* buf, int len, const timeval* tv );
|
2017-09-11 20:51:11 +00:00
|
|
|
|
|
|
|
Socket( const Socket& ) = delete;
|
|
|
|
Socket( Socket&& ) = delete;
|
|
|
|
Socket& operator=( const Socket& ) = delete;
|
|
|
|
Socket& operator=( Socket&& ) = delete;
|
|
|
|
|
|
|
|
private:
|
|
|
|
int m_sock;
|
|
|
|
};
|
|
|
|
|
|
|
|
class ListenSocket
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ListenSocket();
|
|
|
|
~ListenSocket();
|
|
|
|
|
|
|
|
bool Listen( const char* port, int backlog );
|
|
|
|
std::unique_ptr<Socket> Accept();
|
|
|
|
void Close();
|
|
|
|
|
|
|
|
ListenSocket( const ListenSocket& ) = delete;
|
|
|
|
ListenSocket( ListenSocket&& ) = delete;
|
|
|
|
ListenSocket& operator=( const ListenSocket& ) = delete;
|
|
|
|
ListenSocket& operator=( ListenSocket&& ) = delete;
|
|
|
|
|
|
|
|
private:
|
|
|
|
int m_sock;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|