InfNativeSocket

InfNativeSocket — Uniform access to the BSD socket API

Stability Level

Unstable, unless otherwise indicated

Synopsis

#include <libinfinity/common/inf-native-socket.h>

typedef             InfNativeSocket;
#define             INF_NATIVE_SOCKET_EAGAIN
#define             INF_NATIVE_SOCKET_EINPROGRESS
#define             INF_NATIVE_SOCKET_EINTR
#define             INF_NATIVE_SOCKET_LAST_ERROR
#define             INF_NATIVE_SOCKET_SENDRECV_FLAGS
#define             INVALID_SOCKET
GQuark              inf_native_socket_error_quark       (void);
void                inf_native_socket_make_error        (int code,
                                                         GError **error);
#define             closesocket                         (s)

Description

This module provides a common way to access the BSD socket API. While the API is mostly equivalent on Linux and Windows, there are some subtle differences for which uniform identifiers are provided.

Before InfNativeSocket can be used, on Windows WinSock2 must be initialized. You can either do this manually, or call inf_init() which does it for you.

Details

InfNativeSocket

typedef SOCKET InfNativeSocket;

Native socket type on the target platform. This typedef is a simple int on Unix and a SOCKET on Windows.


INF_NATIVE_SOCKET_EAGAIN

# define INF_NATIVE_SOCKET_EAGAIN         WSAEWOULDBLOCK


INF_NATIVE_SOCKET_EINPROGRESS

# define INF_NATIVE_SOCKET_EINPROGRESS    WSAEWOULDBLOCK


INF_NATIVE_SOCKET_EINTR

# define INF_NATIVE_SOCKET_EINTR          WSAEINTR


INF_NATIVE_SOCKET_LAST_ERROR

# define INF_NATIVE_SOCKET_LAST_ERROR     WSAGetLastError()


INF_NATIVE_SOCKET_SENDRECV_FLAGS

# define INF_NATIVE_SOCKET_SENDRECV_FLAGS 0


INVALID_SOCKET

# define INVALID_SOCKET -1


inf_native_socket_error_quark ()

GQuark              inf_native_socket_error_quark       (void);

Returns a GQuark representing the INF_NATIVE_SOCKET_ERROR domain.

Returns :

A GQuark representing the INF_NATIVE_SOCKET_ERROR domain.

inf_native_socket_make_error ()

void                inf_native_socket_make_error        (int code,
                                                         GError **error);

Converts the platform-dependent error code code into a GError. The GError will contain the same numerical value and a platform-dependent human-readable error message.

code :

An error code obtained with INF_NATIVE_SOCKET_LAST_ERROR

error :

Location to store error information.

closesocket()

# define closesocket(s) close(s)