finish io
All checks were successful
Linux arm64 / Build (push) Successful in 19s

This commit is contained in:
2025-06-27 18:53:03 +02:00
parent 0d26879152
commit ed0b06f78d
11 changed files with 443 additions and 54 deletions

View File

@@ -1,6 +1,7 @@
#pragma once
#include <sp/extensions/tcp/TcpSocket.h>
#include <memory>
namespace sp {
namespace io {
@@ -10,7 +11,7 @@ namespace io {
*/
class TcpListener : private NonCopyable {
public:
using SocketHandle = TcpTag::SocketHandle;
using SocketHandle = TcpSocket::SocketHandle;
/**
* \brief Starts listening for guests to connect

View File

@@ -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