44#if defined(ENIGMA_PLATFORM_WINDOWS)
47 const auto err = WSAStartup(MAKEWORD(2, 2), &data);
50 auto err_reason = [err]() ->
const char * {
51#define CASE_RET(c, v) \
55 CASE_RET(WSASYSNOTREADY,
"The underlying network subsystem is not ready for network communication.");
56 CASE_RET(WSAVERNOTSUPPORTED,
"The version of Windows Sockets support requested is not provided by this particular Windows Sockets implementation.");
57 CASE_RET(WSAEINPROGRESS,
"A blocking Windows Sockets 1.1 operation is in progress.");
58 CASE_RET(WSAEPROCLIM,
"A limit on the number of tasks supported by the Windows Sockets implementation has been reached.");
59 CASE_RET(WSAEFAULT,
"The lpWSAData parameter is not a valid pointer.");
61 return "<unknown winsock err>";
66 ENIGMA_ERROR(
"Failed to start WinSock: #{}: {}", err, err_reason());
72 m_socket_fd = socket(AF_INET, SOCK_DGRAM, 0);
75 struct sockaddr_in name {};
76 name.sin_family = AF_INET;
77 name.sin_port = htons(port);
78 name.sin_addr.s_addr = htonl(INADDR_ANY);
79 m_rc = bind(m_socket_fd, (
struct sockaddr *) &name,
sizeof(name));
81 ENIGMA_ERROR(
"Failed to bind socket: {}", std::strerror(errno));
85 ENIGMA_ERROR(
"Failed to create socket: {}", std::strerror(errno));
89 ENIGMA_INFO(
"Created Single Process Instance Socket: {} Port: {}", m_socket_fd, m_port);