Skip to content

Socket Handling

Sebastian Reimers edited this page Apr 7, 2022 · 16 revisions

Win32 (Winsock2.h)

Function Error -> Lookup Return Type
socket() INVALID_SOCKET -> WSAGetLastError() SOCKET (size_t)
accept() INVALID_SOCKET -> WSAGetLastError() SOCKET (size_t)
getsockname() SOCKET_ERROR (-1) -> WSAGetLastError() int
connect() SOCKET_ERROR (-1) -> WSAGetLastError() int

/usr/x86_64-w64-mingw32/include/psdk_inc/_socket_types.h

#if defined(_WIN64)
typedef unsigned __int64 UINT_PTR;
#else 
typedef unsigned int UINT_PTR;
#endif 
typedef UINT_PTR	SOCKET;
#define SOCKET_ERROR   (-1)
#define INVALID_SOCKET (SOCKET)(~0)

Linux/Unix

Function Error -> Lookup Return Type
socket() -1 -> errno int
accept() -1 -> errno int
getsockname() -1 -> errno int
connect() -1 -> errno int
Clone this wiki locally