mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-21 20:53:56 +00:00
Handle listen/accept/send/receive in afd_endpoint
This commit is contained in:
@@ -3,6 +3,11 @@
|
||||
|
||||
namespace network
|
||||
{
|
||||
socket_wrapper::socket_wrapper(SOCKET s)
|
||||
: socket_(s)
|
||||
{
|
||||
}
|
||||
|
||||
socket_wrapper::socket_wrapper(const int af, const int type, const int protocol)
|
||||
: socket_(af, type, protocol)
|
||||
{
|
||||
@@ -23,11 +28,32 @@ namespace network
|
||||
return this->socket_.is_ready(in_poll);
|
||||
}
|
||||
|
||||
bool socket_wrapper::is_listening()
|
||||
{
|
||||
return this->socket_.is_listening();
|
||||
}
|
||||
|
||||
bool socket_wrapper::bind(const address& addr)
|
||||
{
|
||||
return this->socket_.bind(addr);
|
||||
}
|
||||
|
||||
bool socket_wrapper::listen(int backlog)
|
||||
{
|
||||
return this->socket_.listen(backlog);
|
||||
}
|
||||
|
||||
std::unique_ptr<i_socket> socket_wrapper::accept(address& address)
|
||||
{
|
||||
const auto s = this->socket_.accept(address);
|
||||
if (s == INVALID_SOCKET)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return std::make_unique<socket_wrapper>(s);
|
||||
}
|
||||
|
||||
sent_size socket_wrapper::send(const std::span<const std::byte> data)
|
||||
{
|
||||
return ::send(this->socket_.get_socket(), reinterpret_cast<const char*>(data.data()),
|
||||
|
||||
Reference in New Issue
Block a user