This commit is contained in:
@@ -1,14 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <sp/common/NonCopyable.h>
|
||||
#include <sp/io/IOInterface.h>
|
||||
#include <sp/io/IoInterface.h>
|
||||
|
||||
namespace sp {
|
||||
namespace io {
|
||||
|
||||
struct TcpTag {
|
||||
using SocketHandle = int;
|
||||
};
|
||||
class TcpListener;
|
||||
|
||||
class SocketError : public std::exception {
|
||||
private:
|
||||
@@ -22,10 +20,9 @@ class SocketError : public std::exception {
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
class IOInterface<TcpTag> : private NonCopyable {
|
||||
class TcpSocket : public sp::IoInterface {
|
||||
public:
|
||||
using SocketHandle = TcpTag::SocketHandle;
|
||||
using SocketHandle = int;
|
||||
|
||||
/**
|
||||
* \enum Status
|
||||
@@ -40,14 +37,14 @@ class IOInterface<TcpTag> : private NonCopyable {
|
||||
Error,
|
||||
};
|
||||
|
||||
IOInterface();
|
||||
IOInterface(const std::string& a_Host, std::uint16_t a_Port);
|
||||
IOInterface(IOInterface&& a_Other);
|
||||
IOInterface& operator=(IOInterface&& a_Other);
|
||||
virtual ~IOInterface();
|
||||
TcpSocket();
|
||||
TcpSocket(const std::string& a_Host, std::uint16_t a_Port);
|
||||
TcpSocket(TcpSocket&& a_Other);
|
||||
TcpSocket& operator=(TcpSocket&& a_Other);
|
||||
virtual ~TcpSocket();
|
||||
|
||||
DataBuffer Read(std::size_t a_Amount);
|
||||
void Write(const sp::DataBuffer& a_Data);
|
||||
virtual DataBuffer Read(std::size_t a_Amount) override;
|
||||
virtual void Write(const sp::DataBuffer& a_Data) override;
|
||||
|
||||
/**
|
||||
* \brief Allows to set the socket in non blocking/blocking mode
|
||||
@@ -79,10 +76,5 @@ class IOInterface<TcpTag> : private NonCopyable {
|
||||
friend class TcpListener;
|
||||
};
|
||||
|
||||
/**
|
||||
* \typedef TcpSocket
|
||||
*/
|
||||
using TcpSocket = IOInterface<TcpTag>;
|
||||
|
||||
} // namespace io
|
||||
} // namespace sp
|
||||
|
||||
Reference in New Issue
Block a user