Like with stdex::locale_t, this frees us from using Windowsizms on other platforms. Sockets came from Unix to Windows and not the other way around in the first place. Signed-off-by: Simon Rozman <simon@rozman.si>
28 lines
578 B
C++
28 lines
578 B
C++
/*
|
|
SPDX-License-Identifier: MIT
|
|
Copyright © 2023 Amebis
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "compat.hpp"
|
|
#if defined(_WIN32)
|
|
#include "windows.h"
|
|
#include <WinSock2.h>
|
|
#else
|
|
#include <sys/socket.h>
|
|
#include <unistd.h>
|
|
#endif
|
|
|
|
namespace stdex
|
|
{
|
|
#ifdef _WIN32
|
|
using socket_t = SOCKET;
|
|
constexpr socket_t invalid_socket = INVALID_SOCKET;
|
|
inline int closesocket(_In_ socket_t socket) { return ::closesocket(socket); }
|
|
#else
|
|
using socket_t = int;
|
|
constexpr socket_t invalid_socket = ((socket_t)-1);
|
|
inline int closesocket(_In_ socket_t socket) { return ::close(socket); }
|
|
#endif
|
|
} |