iocp 구현하기
This commit is contained in:
45
include/socket/socket.h
Normal file
45
include/socket/socket.h
Normal file
@@ -0,0 +1,45 @@
|
||||
#pragma once
|
||||
#include "address.h"
|
||||
|
||||
namespace Network {
|
||||
|
||||
struct Address;
|
||||
|
||||
class Socket {
|
||||
public:
|
||||
Socket() = default;
|
||||
Socket(int domain, int type, int protocol);
|
||||
~Socket();
|
||||
|
||||
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);
|
||||
|
||||
Socket(const Socket&);
|
||||
Socket(Socket&&) noexcept;
|
||||
Socket& operator=(const Socket&);
|
||||
Socket& operator=(Socket&&) 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