iocp 구현하기

This commit is contained in:
2025-05-31 03:19:58 +09:00
parent 466a80f02b
commit a65483a9c3
55 changed files with 608 additions and 683 deletions

View File

@@ -1,45 +1,15 @@
#pragma once
#include "address.h"
#include "socket.h"
namespace Socket {
namespace Network {
struct Address;
class UDPSocket {
class UDPSocket : public Socket {
public:
UDPSocket() = default;
UDPSocket(int domain, int type, int protocol);
~UDPSocket();
int init(int domain, int type, int protocol);
void destruct();
operator SOCKET();
void set(const SOCKET __sock, int __domain);
int setsockopt(int level, int optname, const char* optval, int optlen);
int bind(Address __addr);
int recvfrom(void* __restrict __buf, size_t __n, int __flags,
struct Address& __addr);
int sendto(const void* __buf, size_t __n, int __flags, struct Address __addr);
UDPSocket(const UDPSocket&);
UDPSocket(UDPSocket&&) noexcept;
UDPSocket& operator=(const UDPSocket&);
UDPSocket& operator=(UDPSocket&&) noexcept;
struct Address bindAddr = {};
struct Address remoteAddr = {};
int domain = 0;
SOCKET sock = INVALID_SOCKET;
std::mutex readMutex;
std::mutex writeMutex;
protected:
bool valid_ = false;
using Socket::init;
using Socket::Socket;
int init(int domain);
};
} // namespace Socket