2015-10-27 08:16:56 +00:00
|
|
|
#ifndef SOCKET_HPP
|
|
|
|
#define SOCKET_HPP
|
|
|
|
|
2015-10-27 15:47:07 +00:00
|
|
|
#include "Athena/Global.hpp"
|
|
|
|
#include "sockwrap.h"
|
|
|
|
|
2015-10-27 08:16:56 +00:00
|
|
|
namespace Athena
|
|
|
|
{
|
|
|
|
namespace net
|
|
|
|
{
|
2015-10-27 15:47:07 +00:00
|
|
|
|
2015-10-27 08:16:56 +00:00
|
|
|
class Socket
|
|
|
|
{
|
2015-10-27 15:47:07 +00:00
|
|
|
// Disable copying
|
2015-10-27 08:16:56 +00:00
|
|
|
public:
|
2015-10-27 15:47:07 +00:00
|
|
|
enum Type
|
|
|
|
{
|
|
|
|
TCP,
|
|
|
|
UDP
|
|
|
|
};
|
|
|
|
|
|
|
|
explicit Socket(Type type = TCP);
|
|
|
|
|
|
|
|
virtual ~Socket() { close() ; }
|
|
|
|
|
|
|
|
void setBlocking(bool blocking);
|
|
|
|
bool isBlocking() const { return m_isBlocking; }
|
|
|
|
protected:
|
|
|
|
sockhandle_t handle() { return m_handle; }
|
|
|
|
void create();
|
|
|
|
void close();
|
2015-10-27 08:16:56 +00:00
|
|
|
private:
|
2015-10-27 15:47:07 +00:00
|
|
|
// Disable copying
|
|
|
|
Socket(const Socket&)=delete;
|
|
|
|
Socket& operator=(const Socket&)=delete;
|
|
|
|
Type m_type;
|
|
|
|
sockhandle_t m_handle;
|
|
|
|
bool m_isBlocking;
|
2015-10-27 08:16:56 +00:00
|
|
|
};
|
2015-10-27 15:47:07 +00:00
|
|
|
|
2015-10-27 08:16:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|