athena/include/Athena/Socket.hpp

45 lines
697 B
C++
Raw Normal View History

2015-10-27 08:16:56 +00:00
#ifndef SOCKET_HPP
#define SOCKET_HPP
#include "Athena/Global.hpp"
#include "sockwrap.h"
2015-10-27 08:16:56 +00:00
namespace Athena
{
namespace net
{
2015-10-27 08:16:56 +00:00
class Socket
{
// Disable copying
2015-10-27 08:16:56 +00:00
public:
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:
// 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 08:16:56 +00:00
}
}
#endif