윈도우용 코드 완성
This commit is contained in:
@@ -1,11 +1,29 @@
|
||||
#include "Socket/Socket_Init.hpp"
|
||||
#include "Socket/Log.hpp"
|
||||
#include "precomp.hpp"
|
||||
|
||||
namespace Chattr {
|
||||
|
||||
Socket_Init::Socket_Init() {
|
||||
Socket_Init::Socket_Init(std::int32_t domain, std::int32_t type, std::int32_t protocol) {
|
||||
#ifdef _WIN32
|
||||
WSADATA wsa;
|
||||
if (WSAStartup(MAKEWORD(2, 2), &wsa) != 0)
|
||||
log::critical("WSAStartup()");
|
||||
#endif
|
||||
sock_ = socket(domain, type, protocol);
|
||||
if (sock_ == INVALID_SOCKET)
|
||||
log::critical("socket()");
|
||||
}
|
||||
|
||||
Socket_Init::~Socket_Init() {
|
||||
#ifdef _WIN32
|
||||
closesocket(sock_);
|
||||
WSACleanup();
|
||||
#elif __linux__
|
||||
close(sock_);
|
||||
#endif
|
||||
}
|
||||
|
||||
SOCKET Socket_Init::get() const { return sock_; }
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user