일단은 멀티로 접속이 됨..

This commit is contained in:
2025-06-19 02:42:49 +09:00
parent 1b79d946c3
commit fc8217a608
25 changed files with 584 additions and 574 deletions

View File

@@ -70,12 +70,13 @@ int Socket::bind(Address __addr) {
int Socket::connect(Address& serveraddr) {
std::string addr_string = serveraddr;
int retVal = -1;
if (serveraddr.family == AF_INET)
if (serveraddr.family == AF_INET) {
retVal = ::connect(sock, (const sockaddr*)&serveraddr.addr_in,
serveraddr.length);
else
} else if (serveraddr.family == AF_INET6) {
retVal = ::connect(sock, (const sockaddr*)&serveraddr.addr_in6,
serveraddr.length);
}
memcpy(&remoteAddr, &serveraddr, sizeof(Address));
if (retVal == INVALID_SOCKET) {
#ifdef _WIN32
@@ -110,12 +111,6 @@ Socket::Socket(const Socket& other_) {
valid_ = false;
}
Socket::Socket(Socket&& other_) noexcept {
other_.valid_ = false;
memcpy(this, &other_, sizeof(Socket));
valid_ = true;
}
Socket& Socket::operator=(const Socket& other_) {
memcpy(this, &other_, sizeof(Socket));
valid_ = false;
@@ -123,6 +118,12 @@ Socket& Socket::operator=(const Socket& other_) {
return *this;
}
Socket::Socket(Socket&& other_) noexcept {
other_.valid_ = false;
memcpy(this, &other_, sizeof(Socket));
valid_ = true;
}
Socket& Socket::operator=(Socket&& other_) noexcept {
other_.valid_ = false;
memcpy(this, &other_, sizeof(Socket));