Add socket abstraction

This commit is contained in:
Maurice Heumann
2025-03-20 15:17:43 +01:00
parent 2cb14a3555
commit 4da6642123
15 changed files with 437 additions and 71 deletions

View File

@@ -0,0 +1,35 @@
#pragma once
#include "i_socket.hpp"
namespace network
{
class socket_wrapper : public i_socket
{
public:
socket_wrapper(int af, int type, int protocol);
~socket_wrapper() override = default;
void set_blocking(bool blocking) override;
int get_last_error() override;
bool is_ready(bool in_poll) override;
bool bind(const address& addr) override;
sent_size send(std::span<const std::byte> data) override;
sent_size sendto(const address& destination, std::span<const std::byte> data) override;
sent_size recv(std::span<std::byte> data) override;
sent_size recvfrom(address& source, std::span<std::byte> data) override;
const socket& get() const
{
return this->socket_;
}
private:
socket socket_{};
};
}