Rebuild directory structure
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user