|  |  |  | GIO Reference Manual |  | 
|---|---|---|---|---|
| Top | Description | Object Hierarchy | Implemented Interfaces | Properties | ||||
GSocketAddress; enum GSocketFamily; GSocketAddress * g_socket_address_new_from_native (gpointer native,gsize len); GSocketFamily g_socket_address_get_family (GSocketAddress *address); gboolean g_socket_address_to_native (GSocketAddress *address,gpointer dest,gsize destlen,GError **error); gssize g_socket_address_get_native_size (GSocketAddress *address);
GObject +----GSocketAddress +----GInetSocketAddress +----GUnixSocketAddress
GEnum +----GSocketFamily
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.
typedef struct _GSocketAddress GSocketAddress;
A socket endpoint address, corresponding to struct sockaddr or one of its subtypes.
typedef enum {
  G_SOCKET_FAMILY_INVALID,
#ifdef GLIB_SYSDEF_AF_UNIX
  G_SOCKET_FAMILY_UNIX = GLIB_SYSDEF_AF_UNIX,
#endif
  G_SOCKET_FAMILY_IPV4 = GLIB_SYSDEF_AF_INET,
  G_SOCKET_FAMILY_IPV6 = GLIB_SYSDEF_AF_INET6
} GSocketFamily;
The protocol family of a GSocketAddress. (These values are
identical to the system defines AF_INET, AF_INET6 and AF_UNIX,
if available.)
| no address family | |
| the UNIX domain family | |
| the IPv4 family | |
| the IPv6 family | 
Since 2.22
GSocketAddress * g_socket_address_new_from_native (gpointer native,gsize len);
Creates a GSocketAddress subclass corresponding to the native
struct sockaddr native.
| 
 | a pointer to a struct sockaddr | 
| 
 | the size of the memory location pointed to by native | 
| Returns : | a new GSocketAddress if nativecould successfully be converted,
otherwiseNULL. | 
Since 2.22
GSocketFamily       g_socket_address_get_family         (GSocketAddress *address);
Gets the socket family type of address.
| 
 | a GSocketAddress | 
| Returns : | the socket family type of address. | 
Since 2.22
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 availible, 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.
| 
 | a GSocketAddress | 
| 
 | a pointer to a memory location that will contain the native struct sockaddr. | 
| 
 | the size of dest. Must be at least as large asg_socket_address_get_native_size(). | 
| 
 | GError for error reporting, or NULLto ignore. | 
| Returns : | TRUEifdestwas filled in,FALSEon error | 
Since 2.22
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().
| 
 | a GSocketAddress | 
| Returns : | the size of the native struct sockaddr that addressrepresents | 
Since 2.22
"family" property"family" GSocketFamily : Read
The family of the socket address.
Default value: G_SOCKET_FAMILY_INVALID