Rebuild directory structure

This commit is contained in:
2026-07-22 22:02:06 +08:00
parent 973b2e60de
commit c5e4d5a3a5
13 changed files with 209 additions and 253 deletions
+21
View File
@@ -0,0 +1,21 @@
#include "socket.hpp"
void Socket::from_addrinfo(const addrinfo &info, AddrAction action) {
s = socket(info.ai_family, info.ai_socktype, info.ai_protocol);
if (s == INVALID_SOCKET) throw -1;
int result = SOCKET_ERROR;
switch (action) {
case NO_ACTION:
break;
case CONNECT:
result = connect(s, info.ai_addr, (int)info.ai_addrlen);
if (result == SOCKET_ERROR) throw result;
break;
case BIND:
result = bind(s, info.ai_addr, (int)info.ai_addrlen);
if (result == SOCKET_ERROR) throw result;
result = listen(s, SOMAXCONN);
if (result == SOCKET_ERROR) throw result;
break;
}
}