## InfNativeSocket InfNativeSocket — Uniform access to the BSD socket API |

## Stability Level

Unstable, unless otherwise indicated

## Functions

GQuark | inf_native_socket_error_quark ()
void | inf_native_socket_make_error ()
#define | closesocket()

## Types and Values

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

## Includes

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

## 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.

## Functions

### 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.

#### Parameters

code | An error code obtained with INF_NATIVE_SOCKET_LAST_ERROR |
error | Location to store error information. |

### closesocket()

    # define closesocket(s) close(s)

## Types and Values

### 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