16#include <sys/socket.h>
25 using socket_t = SOCKET;
26 constexpr socket_t invalid_socket = INVALID_SOCKET;
27 inline int closesocket(_In_ socket_t socket) { return ::closesocket(socket); }
30 constexpr socket_t invalid_socket = ((socket_t)-1);
31 inline int closesocket(_In_ socket_t socket) { return ::close(socket); }
39 static inline const socket_t invalid_handle = stdex::invalid_socket;
44 static void close(_In_ socket_t h)
46 int result = closesocket(h);
48 int werrno = WSAGetLastError();
49 if (result >= 0 || werrno == WSAENOTSOCK)
51 throw std::system_error(werrno, std::system_category(),
"closesocket failed");
53 if (result >= 0 || errno == EBADF)
55 throw std::system_error(errno, std::system_category(),
"closesocket failed");
63 using socket = basic_sys_object<socket_t, socket_traits>;
82 using addrinfo = std::unique_ptr<struct addrinfo, freeaddrinfo_delete>;
88 struct FreeAddrInfoW_delete
93 void operator()(_In_ ADDRINFOW* ptr)
const
102 using waddrinfo = std::unique_ptr<ADDRINFOW, FreeAddrInfoW_delete>;
108 using saddrinfo = waddrinfo;
110 using saddrinfo = addrinfo;
113 using saddrinfo = addrinfo;
Deleter for unique_ptr using freeaddrinfo.
Definition socket.hpp:69
void operator()(struct ::addrinfo *ptr) const
Delete a pointer.
Definition socket.hpp:73
Socket operations.
Definition socket.hpp:38
static void close(socket_t h)
Closes socket.
Definition socket.hpp:44