tcp/udp 추가, todo:iocp openssl 지원하도록 업데이트하기
This commit is contained in:
45
include/socket/udp_socket.h
Normal file
45
include/socket/udp_socket.h
Normal 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
|
||||
Reference in New Issue
Block a user