## GSocketAddress GSocketAddress — Abstract base class representing endpoints for socket communication |

## Functions

GSocketAddress * | g_socket_address_new_from_native ()
GSocketFamily | g_socket_address_get_family ()
gboolean | g_socket_address_to_native ()
gssize | g_socket_address_get_native_size ()

## Properties

GSocketFamily | family | Read

## Types and Values

| GSocketAddress
enum | GSocketFamily

## Object Hierarchy

        GEnum
        ╰── GSocketFamily
        GObject
        ╰── GSocketAddress
            ├── GInetSocketAddress
            ├── GNativeSocketAddress
            ╰── GUnixSocketAddress

## Implemented Interfaces

GSocketAddress implements GSocketConnectable.

## Includes

    #include <gio/gio.h>

## Description

GSocketAddress is the equivalent of struct sockaddr in the BSD sockets API. This is an abstract class; use GInetSocketAddress for internet sockets, or GUnixSocketAddress for UNIX domain sockets.

## Functions

### g_socket_address_new_from_native ()

    GSocketAddress *
    g_socket_address_new_from_native (gpointer native,
                                      gsize len);

Creates a GSocketAddress subclass corresponding to the native struct sockaddr `native` .

#### Parameters

native | a pointer to a struct sockaddr. | [not nullable]
len | the size of the memory location pointed to by `native` |

#### Returns

a new GSocketAddress if `native` could successfully be converted, otherwise `NULL`

Since: 2.22

### g_socket_address_get_family ()

    GSocketFamily
    g_socket_address_get_family (GSocketAddress *address);

Gets the socket family type of `address` .

#### Parameters

address | a GSocketAddress |

#### Returns

the socket family type of `address`

Since: 2.22

### g_socket_address_to_native ()

    gboolean
    g_socket_address_to_native (GSocketAddress *address,
                                gpointer dest,
                                gsize destlen,
                                GError **error);

Converts a GSocketAddress to a native struct sockaddr, which can be passed to low-level functions like `connect()` or `bind()`.

If not enough space is available, a `G_IO_ERROR_NO_SPACE` error is returned. If the address type is not known on the system then a `G_IO_ERROR_NOT_SUPPORTED` error is returned.

#### Parameters

address | a GSocketAddress |
dest | a pointer to a memory location that will contain the native struct sockaddr |
destlen | the size of `dest` . Must be at least as large as `g_socket_address_get_native_size()` |
error | GError for error reporting, or `NULL` to ignore |

#### Returns

`TRUE` if `dest` was filled in, `FALSE` on error

Since: 2.22

### g_socket_address_get_native_size ()

    gssize
    g_socket_address_get_native_size (GSocketAddress *address);

Gets the size of `address` 's native struct sockaddr. You can use this to allocate memory to pass to `g_socket_address_to_native()`.

#### Parameters

address | a GSocketAddress |

#### Returns

the size of the native struct sockaddr that `address` represents

Since: 2.22

## Types and Values

### GSocketAddress

    typedef struct _GSocketAddress GSocketAddress;

A socket endpoint address, corresponding to struct sockaddr or one of its subtypes.

### enum GSocketFamily

The protocol family of a GSocketAddress. (These values are identical to the system defines `AF_INET`, `AF_INET6` and `AF_UNIX`, if available.)

#### Members

G_SOCKET_FAMILY_INVALID | no address family |
G_SOCKET_FAMILY_UNIX | the UNIX domain family |
G_SOCKET_FAMILY_IPV4 | the IPv4 family |
G_SOCKET_FAMILY_IPV6 | the IPv6 family |

Since: 2.22

## Property Details

### The `“family”` property

      “family”                   GSocketFamily

The family of the socket address.

Flags: Read

Default value: G_SOCKET_FAMILY_INVALID