Files
NP_Midterm/include/Socket/Socket.hpp
2025-05-02 12:05:57 +09:00

40 lines
954 B
C++

#pragma once
#include "Socket/Address.hpp"
namespace Chattr {
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 FAR* 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&) = delete;
Socket(Socket&&) noexcept;
Socket& operator=(const Socket&) = delete;
Socket& operator=(Socket&&) noexcept;
struct Address bindAddr = {};
struct Address remoteAddr = {};
int domain = 0;
SOCKET sock = INVALID_SOCKET;
protected:
bool valid_ = false;
};
}