<?xml version="1.0"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" 
               "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
<!ENTITY version SYSTEM "version.xml">
]>
<refentry id="GSocketAddress">
<refmeta>
<refentrytitle role="top_of_page" id="GSocketAddress.top_of_page">GSocketAddress</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>GIO Library</refmiscinfo>
</refmeta>

<refnamediv>
<refname>GSocketAddress</refname>
<refpurpose>Abstract base class representing endpoints for
socket communication</refpurpose>
</refnamediv>

<refsynopsisdiv id="GSocketAddress.synopsis" role="synopsis">
<title role="synopsis.title">Synopsis</title>

<synopsis>
                    <link linkend="GSocketAddress-struct">GSocketAddress</link>;
enum                <link linkend="GSocketFamily">GSocketFamily</link>;
<link linkend="GSocketAddress">GSocketAddress</link> *    <link linkend="g-socket-address-new-from-native">g_socket_address_new_from_native</link>    (<link linkend="gpointer">gpointer</link> native,
                                                         <link linkend="gsize">gsize</link> len);
<link linkend="GSocketFamily">GSocketFamily</link>       <link linkend="g-socket-address-get-family">g_socket_address_get_family</link>         (<link linkend="GSocketAddress">GSocketAddress</link> *address);
<link linkend="gboolean">gboolean</link>            <link linkend="g-socket-address-to-native">g_socket_address_to_native</link>          (<link linkend="GSocketAddress">GSocketAddress</link> *address,
                                                         <link linkend="gpointer">gpointer</link> dest,
                                                         <link linkend="gsize">gsize</link> destlen,
                                                         <link linkend="GError">GError</link> **error);
<link linkend="gssize">gssize</link>              <link linkend="g-socket-address-get-native-size">g_socket_address_get_native_size</link>    (<link linkend="GSocketAddress">GSocketAddress</link> *address);
</synopsis>
</refsynopsisdiv>

<refsect1 id="GSocketAddress.object-hierarchy" role="object_hierarchy">
<title role="object_hierarchy.title">Object Hierarchy</title>
<synopsis>
  <link linkend="GObject">GObject</link>
   +----GSocketAddress
         +----<link linkend="GInetSocketAddress">GInetSocketAddress</link>
         +----<link linkend="GUnixSocketAddress">GUnixSocketAddress</link>
</synopsis>
</refsect1>



<refsect1 id="GSocketAddress.implemented-interfaces" role="impl_interfaces">
<title role="impl_interfaces.title">Implemented Interfaces</title>
<para>
GSocketAddress implements
 <link linkend="GSocketConnectable">GSocketConnectable</link>.</para>
</refsect1>


<refsect1 id="GSocketAddress.properties" role="properties">
<title role="properties.title">Properties</title>
<synopsis>
  &quot;<link linkend="GSocketAddress--family">family</link>&quot;                   <link linkend="GSocketFamily">GSocketFamily</link>         : Read
</synopsis>
</refsect1>



<refsect1 id="GSocketAddress.description" role="desc">
<title role="desc.title">Description</title>
<para>
<link linkend="GSocketAddress"><type>GSocketAddress</type></link> is the equivalent of <type>struct sockaddr</type>
in the BSD sockets API. This is an abstract class; use
<link linkend="GInetSocketAddress"><type>GInetSocketAddress</type></link> for internet sockets, or <link linkend="GUnixSocketAddress"><type>GUnixSocketAddress</type></link>
for UNIX domain sockets.</para>
<para>
</para>
</refsect1>

<refsect1 id="GSocketAddress.details" role="details">
<title role="details.title">Details</title>
<refsect2 id="GSocketAddress-struct" role="struct">
<title>GSocketAddress</title>
<indexterm zone="GSocketAddress-struct"><primary sortas="SocketAddress">GSocketAddress</primary></indexterm><programlisting>typedef struct _GSocketAddress GSocketAddress;</programlisting>
<para>
A socket endpoint address, corresponding to <type>struct sockaddr</type>
or one of its subtypes.</para>
<para>
</para></refsect2>
<refsect2 id="GSocketFamily" role="enum" condition="since:2.22">
<title>enum GSocketFamily</title>
<indexterm zone="GSocketFamily" role="2.22"><primary sortas="SocketFamily">GSocketFamily</primary></indexterm><programlisting>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;
</programlisting>
<para>
The protocol family of a <link linkend="GSocketAddress"><type>GSocketAddress</type></link>. (These values are
identical to the system defines <link linkend="AF-INET--CAPS"><literal>AF_INET</literal></link>, <link linkend="AF-INET6--CAPS"><literal>AF_INET6</literal></link> and <link linkend="AF-UNIX--CAPS"><literal>AF_UNIX</literal></link>,
if available.)</para>
<para>
</para><variablelist role="enum">
<varlistentry id="G-SOCKET-FAMILY-INVALID--CAPS" role="constant">
<term><literal>G_SOCKET_FAMILY_INVALID</literal></term>
<listitem><simpara> no address family
</simpara></listitem>
</varlistentry>
<varlistentry id="G-SOCKET-FAMILY-UNIX--CAPS" role="constant">
<term><literal>G_SOCKET_FAMILY_UNIX</literal></term>
<listitem><simpara> the UNIX domain family
</simpara></listitem>
</varlistentry>
<varlistentry id="G-SOCKET-FAMILY-IPV4--CAPS" role="constant">
<term><literal>G_SOCKET_FAMILY_IPV4</literal></term>
<listitem><simpara> the IPv4 family
</simpara></listitem>
</varlistentry>
<varlistentry id="G-SOCKET-FAMILY-IPV6--CAPS" role="constant">
<term><literal>G_SOCKET_FAMILY_IPV6</literal></term>
<listitem><simpara> the IPv6 family
</simpara></listitem>
</varlistentry>
</variablelist><para role="since">Since 2.22</para></refsect2>
<refsect2 id="g-socket-address-new-from-native" role="function" condition="since:2.22">
<title>g_socket_address_new_from_native ()</title>
<indexterm zone="g-socket-address-new-from-native" role="2.22"><primary sortas="socket_address_new_from_native">g_socket_address_new_from_native</primary></indexterm><programlisting><link linkend="GSocketAddress">GSocketAddress</link> *    g_socket_address_new_from_native    (<link linkend="gpointer">gpointer</link> native,
                                                         <link linkend="gsize">gsize</link> len);</programlisting>
<para>
Creates a <link linkend="GSocketAddress"><type>GSocketAddress</type></link> subclass corresponding to the native
<type>struct sockaddr</type> <parameter>native</parameter>.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>native</parameter>&#160;:</term>
<listitem><simpara> a pointer to a <type>struct sockaddr</type>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>len</parameter>&#160;:</term>
<listitem><simpara> the size of the memory location pointed to by <parameter>native</parameter>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> a new <link linkend="GSocketAddress"><type>GSocketAddress</type></link> if <parameter>native</parameter> could successfully be converted,
otherwise <link linkend="NULL--CAPS"><literal>NULL</literal></link>.

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.22</para></refsect2>
<refsect2 id="g-socket-address-get-family" role="function" condition="since:2.22">
<title>g_socket_address_get_family ()</title>
<indexterm zone="g-socket-address-get-family" role="2.22"><primary sortas="socket_address_get_family">g_socket_address_get_family</primary></indexterm><programlisting><link linkend="GSocketFamily">GSocketFamily</link>       g_socket_address_get_family         (<link linkend="GSocketAddress">GSocketAddress</link> *address);</programlisting>
<para>
Gets the socket family type of <parameter>address</parameter>.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>address</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GSocketAddress"><type>GSocketAddress</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> the socket family type of <parameter>address</parameter>.

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.22</para></refsect2>
<refsect2 id="g-socket-address-to-native" role="function" condition="since:2.22">
<title>g_socket_address_to_native ()</title>
<indexterm zone="g-socket-address-to-native" role="2.22"><primary sortas="socket_address_to_native">g_socket_address_to_native</primary></indexterm><programlisting><link linkend="gboolean">gboolean</link>            g_socket_address_to_native          (<link linkend="GSocketAddress">GSocketAddress</link> *address,
                                                         <link linkend="gpointer">gpointer</link> dest,
                                                         <link linkend="gsize">gsize</link> destlen,
                                                         <link linkend="GError">GError</link> **error);</programlisting>
<para>
Converts a <link linkend="GSocketAddress"><type>GSocketAddress</type></link> to a native <type>struct
sockaddr</type>, which can be passed to low-level functions like
<link linkend="connect"><function>connect()</function></link> or <link linkend="bind"><function>bind()</function></link>.
</para>
<para>
If not enough space is availible, a <link linkend="G-IO-ERROR-NO-SPACE--CAPS"><literal>G_IO_ERROR_NO_SPACE</literal></link> error is
returned. If the address type is not known on the system
then a <link linkend="G-IO-ERROR-NOT-SUPPORTED--CAPS"><literal>G_IO_ERROR_NOT_SUPPORTED</literal></link> error is returned.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>address</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GSocketAddress"><type>GSocketAddress</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>dest</parameter>&#160;:</term>
<listitem><simpara> a pointer to a memory location that will contain the native
<type>struct sockaddr</type>.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>destlen</parameter>&#160;:</term>
<listitem><simpara> the size of <parameter>dest</parameter>. Must be at least as large as
<link linkend="g-socket-address-get-native-size"><function>g_socket_address_get_native_size()</function></link>.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>error</parameter>&#160;:</term>
<listitem><simpara> <link linkend="GError"><type>GError</type></link> for error reporting, or <link linkend="NULL--CAPS"><literal>NULL</literal></link> to ignore.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> <link linkend="TRUE--CAPS"><literal>TRUE</literal></link> if <parameter>dest</parameter> was filled in, <link linkend="FALSE--CAPS"><literal>FALSE</literal></link> on error

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.22</para></refsect2>
<refsect2 id="g-socket-address-get-native-size" role="function" condition="since:2.22">
<title>g_socket_address_get_native_size ()</title>
<indexterm zone="g-socket-address-get-native-size" role="2.22"><primary sortas="socket_address_get_native_size">g_socket_address_get_native_size</primary></indexterm><programlisting><link linkend="gssize">gssize</link>              g_socket_address_get_native_size    (<link linkend="GSocketAddress">GSocketAddress</link> *address);</programlisting>
<para>
Gets the size of <parameter>address</parameter>'s native <type>struct sockaddr</type>.
You can use this to allocate memory to pass to
<link linkend="g-socket-address-to-native"><function>g_socket_address_to_native()</function></link>.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>address</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GSocketAddress"><type>GSocketAddress</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> the size of the native <type>struct sockaddr</type> that
    <parameter>address</parameter> represents

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.22</para></refsect2>

</refsect1>
<refsect1 id="GSocketAddress.property-details" role="property_details">
<title role="property_details.title">Property Details</title>
<refsect2 id="GSocketAddress--family" role="property"><title>The <literal>&quot;family&quot;</literal> property</title>
<indexterm zone="GSocketAddress--family"><primary sortas="SocketAddress:family">GSocketAddress:family</primary></indexterm><programlisting>  &quot;family&quot;                   <link linkend="GSocketFamily">GSocketFamily</link>         : Read</programlisting>
<para>The family of the socket address.</para><para>Default value: G_SOCKET_FAMILY_INVALID</para>
</refsect2>
</refsect1>




</refentry>
