1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <title>GSocketAddress</title>
6 <meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
7 <link rel="home" href="index.html" title="GIO Reference Manual">
8 <link rel="up" href="networking.html" title="Low-level network support">
9 <link rel="prev" href="gio-GInetAddressMask.html" title="GInetAddressMask">
10 <link rel="next" href="GInetSocketAddress.html" title="GInetSocketAddress">
11 <meta name="generator" content="GTK-Doc V1.18 (XML mode)">
12 <link rel="stylesheet" href="style.css" type="text/css">
14 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
15 <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
17 <td><a accesskey="p" href="gio-GInetAddressMask.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
18 <td><a accesskey="u" href="networking.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
19 <td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
20 <th width="100%" align="center">GIO Reference Manual</th>
21 <td><a accesskey="n" href="GInetSocketAddress.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
23 <tr><td colspan="5" class="shortcuts">
24 <a href="#GSocketAddress.synopsis" class="shortcut">Top</a>
26 <a href="#GSocketAddress.description" class="shortcut">Description</a>
28 <a href="#GSocketAddress.object-hierarchy" class="shortcut">Object Hierarchy</a>
30 <a href="#GSocketAddress.implemented-interfaces" class="shortcut">Implemented Interfaces</a>
32 <a href="#GSocketAddress.properties" class="shortcut">Properties</a>
35 <div class="refentry">
36 <a name="GSocketAddress"></a><div class="titlepage"></div>
37 <div class="refnamediv"><table width="100%"><tr>
39 <h2><span class="refentrytitle"><a name="GSocketAddress.top_of_page"></a>GSocketAddress</span></h2>
40 <p>GSocketAddress — Abstract base class representing endpoints for
41 socket communication</p>
43 <td valign="top" align="right"></td>
45 <div class="refsynopsisdiv">
46 <a name="GSocketAddress.synopsis"></a><h2>Synopsis</h2>
47 <pre class="synopsis"> <a class="link" href="GSocketAddress.html#GSocketAddress-struct" title="GSocketAddress">GSocketAddress</a>;
48 enum <a class="link" href="GSocketAddress.html#GSocketFamily" title="enum GSocketFamily">GSocketFamily</a>;
49 <a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="returnvalue">GSocketAddress</span></a> * <a class="link" href="GSocketAddress.html#g-socket-address-new-from-native" title="g_socket_address_new_from_native ()">g_socket_address_new_from_native</a> (<em class="parameter"><code><a href="./../glib/glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> native</code></em>,
50 <em class="parameter"><code><a href="./../glib/glib/glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> len</code></em>);
51 <a class="link" href="GSocketAddress.html#GSocketFamily" title="enum GSocketFamily"><span class="returnvalue">GSocketFamily</span></a> <a class="link" href="GSocketAddress.html#g-socket-address-get-family" title="g_socket_address_get_family ()">g_socket_address_get_family</a> (<em class="parameter"><code><a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a> *address</code></em>);
52 <a href="./../glib/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> <a class="link" href="GSocketAddress.html#g-socket-address-to-native" title="g_socket_address_to_native ()">g_socket_address_to_native</a> (<em class="parameter"><code><a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a> *address</code></em>,
53 <em class="parameter"><code><a href="./../glib/glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> dest</code></em>,
54 <em class="parameter"><code><a href="./../glib/glib/glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> destlen</code></em>,
55 <em class="parameter"><code><a href="./../glib/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);
56 <a href="./../glib/glib/glib-Basic-Types.html#gssize"><span class="returnvalue">gssize</span></a> <a class="link" href="GSocketAddress.html#g-socket-address-get-native-size" title="g_socket_address_get_native_size ()">g_socket_address_get_native_size</a> (<em class="parameter"><code><a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a> *address</code></em>);
59 <div class="refsect1">
60 <a name="GSocketAddress.object-hierarchy"></a><h2>Object Hierarchy</h2>
61 <pre class="synopsis">
62 <a href="./../gobject/gobject/gobject-The-Base-Object-Type.html#GObject">GObject</a>
64 +----<a class="link" href="GInetSocketAddress.html" title="GInetSocketAddress">GInetSocketAddress</a>
65 +----<a class="link" href="GUnixSocketAddress.html" title="GUnixSocketAddress">GUnixSocketAddress</a>
68 <div class="refsect1">
69 <a name="GSocketAddress.implemented-interfaces"></a><h2>Implemented Interfaces</h2>
71 GSocketAddress implements
72 <a class="link" href="GSocketConnectable.html" title="GSocketConnectable">GSocketConnectable</a>.</p>
74 <div class="refsect1">
75 <a name="GSocketAddress.properties"></a><h2>Properties</h2>
76 <pre class="synopsis">
77 "<a class="link" href="GSocketAddress.html#GSocketAddress--family" title='The "family" property'>family</a>" <a class="link" href="GSocketAddress.html#GSocketFamily" title="enum GSocketFamily"><span class="type">GSocketFamily</span></a> : Read
80 <div class="refsect1">
81 <a name="GSocketAddress.description"></a><h2>Description</h2>
83 <a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a> is the equivalent of <span class="type">struct sockaddr</span>
84 in the BSD sockets API. This is an abstract class; use
85 <a class="link" href="GInetSocketAddress.html" title="GInetSocketAddress"><span class="type">GInetSocketAddress</span></a> for internet sockets, or <a class="link" href="GUnixSocketAddress.html" title="GUnixSocketAddress"><span class="type">GUnixSocketAddress</span></a>
86 for UNIX domain sockets.
89 <div class="refsect1">
90 <a name="GSocketAddress.details"></a><h2>Details</h2>
91 <div class="refsect2">
92 <a name="GSocketAddress-struct"></a><h3>GSocketAddress</h3>
93 <pre class="programlisting">typedef struct _GSocketAddress GSocketAddress;</pre>
95 A socket endpoint address, corresponding to <span class="type">struct sockaddr</span>
96 or one of its subtypes.
100 <div class="refsect2">
101 <a name="GSocketFamily"></a><h3>enum GSocketFamily</h3>
102 <pre class="programlisting">typedef enum {
103 G_SOCKET_FAMILY_INVALID,
104 G_SOCKET_FAMILY_UNIX = GLIB_SYSDEF_AF_UNIX,
105 G_SOCKET_FAMILY_IPV4 = GLIB_SYSDEF_AF_INET,
106 G_SOCKET_FAMILY_IPV6 = GLIB_SYSDEF_AF_INET6
110 The protocol family of a <a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a>. (These values are
111 identical to the system defines <code class="literal">AF_INET</code>, <code class="literal">AF_INET6</code> and <code class="literal">AF_UNIX</code>,
114 <div class="variablelist"><table border="0">
115 <col align="left" valign="top">
118 <td><p><a name="G-SOCKET-FAMILY-INVALID:CAPS"></a><span class="term"><code class="literal">G_SOCKET_FAMILY_INVALID</code></span></p></td>
119 <td>no address family
123 <td><p><a name="G-SOCKET-FAMILY-UNIX:CAPS"></a><span class="term"><code class="literal">G_SOCKET_FAMILY_UNIX</code></span></p></td>
124 <td>the UNIX domain family
128 <td><p><a name="G-SOCKET-FAMILY-IPV4:CAPS"></a><span class="term"><code class="literal">G_SOCKET_FAMILY_IPV4</code></span></p></td>
133 <td><p><a name="G-SOCKET-FAMILY-IPV6:CAPS"></a><span class="term"><code class="literal">G_SOCKET_FAMILY_IPV6</code></span></p></td>
139 <p class="since">Since 2.22</p>
142 <div class="refsect2">
143 <a name="g-socket-address-new-from-native"></a><h3>g_socket_address_new_from_native ()</h3>
144 <pre class="programlisting"><a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="returnvalue">GSocketAddress</span></a> * g_socket_address_new_from_native (<em class="parameter"><code><a href="./../glib/glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> native</code></em>,
145 <em class="parameter"><code><a href="./../glib/glib/glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> len</code></em>);</pre>
147 Creates a <a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a> subclass corresponding to the native
148 <span class="type">struct sockaddr</span> <em class="parameter"><code>native</code></em>.
150 <div class="variablelist"><table border="0">
151 <col align="left" valign="top">
154 <td><p><span class="term"><em class="parameter"><code>native</code></em> :</span></p></td>
155 <td>a pointer to a <span class="type">struct sockaddr</span>
159 <td><p><span class="term"><em class="parameter"><code>len</code></em> :</span></p></td>
160 <td>the size of the memory location pointed to by <em class="parameter"><code>native</code></em>
164 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
165 <td>a new <a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a> if <em class="parameter"><code>native</code></em> could successfully be converted,
166 otherwise <a href="./../glib/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>.</td>
170 <p class="since">Since 2.22</p>
173 <div class="refsect2">
174 <a name="g-socket-address-get-family"></a><h3>g_socket_address_get_family ()</h3>
175 <pre class="programlisting"><a class="link" href="GSocketAddress.html#GSocketFamily" title="enum GSocketFamily"><span class="returnvalue">GSocketFamily</span></a> g_socket_address_get_family (<em class="parameter"><code><a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a> *address</code></em>);</pre>
177 Gets the socket family type of <em class="parameter"><code>address</code></em>.
179 <div class="variablelist"><table border="0">
180 <col align="left" valign="top">
183 <td><p><span class="term"><em class="parameter"><code>address</code></em> :</span></p></td>
184 <td>a <a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a>
188 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
189 <td>the socket family type of <em class="parameter"><code>address</code></em>.</td>
193 <p class="since">Since 2.22</p>
196 <div class="refsect2">
197 <a name="g-socket-address-to-native"></a><h3>g_socket_address_to_native ()</h3>
198 <pre class="programlisting"><a href="./../glib/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> g_socket_address_to_native (<em class="parameter"><code><a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a> *address</code></em>,
199 <em class="parameter"><code><a href="./../glib/glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> dest</code></em>,
200 <em class="parameter"><code><a href="./../glib/glib/glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> destlen</code></em>,
201 <em class="parameter"><code><a href="./../glib/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);</pre>
203 Converts a <a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a> to a native <span class="type">struct
204 sockaddr</span>, which can be passed to low-level functions like
205 <code class="function">connect()</code> or <code class="function">bind()</code>.
208 If not enough space is available, a <a class="link" href="gio-GIOError.html#G-IO-ERROR-NO-SPACE:CAPS"><code class="literal">G_IO_ERROR_NO_SPACE</code></a> error is
209 returned. If the address type is not known on the system
210 then a <a class="link" href="gio-GIOError.html#G-IO-ERROR-NOT-SUPPORTED:CAPS"><code class="literal">G_IO_ERROR_NOT_SUPPORTED</code></a> error is returned.
212 <div class="variablelist"><table border="0">
213 <col align="left" valign="top">
216 <td><p><span class="term"><em class="parameter"><code>address</code></em> :</span></p></td>
217 <td>a <a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a>
221 <td><p><span class="term"><em class="parameter"><code>dest</code></em> :</span></p></td>
222 <td>a pointer to a memory location that will contain the native
223 <span class="type">struct sockaddr</span>.</td>
226 <td><p><span class="term"><em class="parameter"><code>destlen</code></em> :</span></p></td>
227 <td>the size of <em class="parameter"><code>dest</code></em>. Must be at least as large as
228 <a class="link" href="GSocketAddress.html#g-socket-address-get-native-size" title="g_socket_address_get_native_size ()"><code class="function">g_socket_address_get_native_size()</code></a>.</td>
231 <td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td>
233 <a href="./../glib/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> for error reporting, or <a href="./../glib/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore.</td>
236 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
238 <a href="./../glib/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if <em class="parameter"><code>dest</code></em> was filled in, <a href="./../glib/glib/glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> on error</td>
242 <p class="since">Since 2.22</p>
245 <div class="refsect2">
246 <a name="g-socket-address-get-native-size"></a><h3>g_socket_address_get_native_size ()</h3>
247 <pre class="programlisting"><a href="./../glib/glib/glib-Basic-Types.html#gssize"><span class="returnvalue">gssize</span></a> g_socket_address_get_native_size (<em class="parameter"><code><a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a> *address</code></em>);</pre>
249 Gets the size of <em class="parameter"><code>address</code></em>'s native <span class="type">struct sockaddr</span>.
250 You can use this to allocate memory to pass to
251 <a class="link" href="GSocketAddress.html#g-socket-address-to-native" title="g_socket_address_to_native ()"><code class="function">g_socket_address_to_native()</code></a>.
253 <div class="variablelist"><table border="0">
254 <col align="left" valign="top">
257 <td><p><span class="term"><em class="parameter"><code>address</code></em> :</span></p></td>
258 <td>a <a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a>
262 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
263 <td>the size of the native <span class="type">struct sockaddr</span> that
264 <em class="parameter"><code>address</code></em> represents</td>
268 <p class="since">Since 2.22</p>
271 <div class="refsect1">
272 <a name="GSocketAddress.property-details"></a><h2>Property Details</h2>
273 <div class="refsect2">
274 <a name="GSocketAddress--family"></a><h3>The <code class="literal">"family"</code> property</h3>
275 <pre class="programlisting"> "family" <a class="link" href="GSocketAddress.html#GSocketFamily" title="enum GSocketFamily"><span class="type">GSocketFamily</span></a> : Read</pre>
276 <p>The family of the socket address.</p>
277 <p>Default value: G_SOCKET_FAMILY_INVALID</p>
283 Generated by GTK-Doc V1.18</div>