tcp/udp 추가, todo:iocp openssl 지원하도록 업데이트하기

This commit is contained in:
2025-05-27 21:52:21 +09:00
parent 27f1e63c98
commit 466a80f02b
25 changed files with 1056 additions and 6 deletions

View File

@@ -0,0 +1,45 @@
#pragma once
#include "address.h"
namespace Socket {
struct Address;
class UDPSocket {
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;
};
} // namespace Socket