| Server IP : 182.53.201.61 / Your IP : 216.73.217.175 Web Server : Apache/2.2.15 (Fedora) System : Linux km10.dyndns.org 2.6.31.5-127.fc12.i686.PAE #1 SMP Sat Nov 7 21:25:57 EST 2009 i686 User : apache ( 48) PHP Version : 5.3.3 Disable Function : NONE MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/share/gtk-doc/html/gio/ |
Upload File : |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>GSocketConnectable</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="index.html" title="GIO Reference Manual">
<link rel="up" href="resolver.html" title="DNS resolution">
<link rel="prev" href="GResolver.html" title="GResolver">
<link rel="next" href="GNetworkAddress.html" title="GNetworkAddress">
<meta name="generator" content="GTK-Doc V1.11 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
<link rel="part" href="pt01.html" title="Part I. GIO Overview">
<link rel="chapter" href="ch01.html" title="Introduction">
<link rel="chapter" href="ch02.html" title="Compiling GIO applications">
<link rel="chapter" href="ch03.html" title="Running GIO applications">
<link rel="chapter" href="extending-gio.html" title="Extending GIO">
<link rel="part" href="pt02.html" title="Part II. API Reference">
<link rel="chapter" href="file_ops.html" title="File Operations">
<link rel="chapter" href="file_mon.html" title="File System Monitoring">
<link rel="chapter" href="async.html" title="Asynchronous I/O">
<link rel="chapter" href="streaming.html" title="Streaming I/O">
<link rel="chapter" href="types.html" title="File types and applications">
<link rel="chapter" href="volume_mon.html" title="Volumes and Drives">
<link rel="chapter" href="icons.html" title="Icons">
<link rel="chapter" href="failable_initialization.html" title="Failable Initialization">
<link rel="chapter" href="networking.html" title="Lowlevel platform-independent network support">
<link rel="chapter" href="resolver.html" title="DNS resolution">
<link rel="chapter" href="highlevel-socket.html" title="Highlevel network functionallity">
<link rel="chapter" href="utils.html" title="Utilities">
<link rel="chapter" href="extending.html" title="Extending GIO">
<link rel="part" href="migrating.html" title="Part III. Migrating to GIO">
<link rel="chapter" href="ch18.html" title="Migrating from POSIX to GIO">
<link rel="chapter" href="ch19.html" title="Migrating from GnomeVFS to GIO">
<link rel="chapter" href="gio-hierarchy.html" title="Object Hierarchy">
<link rel="index" href="ix01.html" title="Index">
<link rel="index" href="ix02.html" title="Index of deprecated symbols">
<link rel="index" href="ix03.html" title="Index of new symbols in 2.18">
<link rel="index" href="ix04.html" title="Index of new symbols in 2.20">
<link rel="index" href="ix05.html" title="Index of new symbols in 2.22">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
<tr valign="middle">
<td><a accesskey="p" href="GResolver.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="resolver.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">GIO Reference Manual</th>
<td><a accesskey="n" href="GNetworkAddress.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr>
<tr><td colspan="5" class="shortcuts">
<a href="#GSocketConnectable.synopsis" class="shortcut">Top</a>
|
<a href="#GSocketConnectable.description" class="shortcut">Description</a>
|
<a href="#GSocketConnectable.object-hierarchy" class="shortcut">Object Hierarchy</a>
|
<a href="#GSocketConnectable.prerequisites" class="shortcut">Prerequisites</a>
|
<a href="#GSocketConnectable.implementations" class="shortcut">Known Implementations</a>
</td></tr>
</table>
<div class="refentry" title="GSocketConnectable">
<a name="GSocketConnectable"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2><span class="refentrytitle"><a name="GSocketConnectable.top_of_page"></a>GSocketConnectable</span></h2>
<p>GSocketConnectable — Interface for potential socket endpoints</p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsynopsisdiv" title="Synopsis">
<a name="GSocketConnectable.synopsis"></a><h2>Synopsis</h2>
<a name="GSocketAddressEnumerator"></a><pre class="synopsis">
<a class="link" href="GSocketConnectable.html#GSocketConnectable-struct" title="GSocketConnectable">GSocketConnectable</a>;
<a class="link" href="GSocketConnectable.html#GSocketConnectableIface" title="GSocketConnectableIface">GSocketConnectableIface</a>;
<a class="link" href="GSocketConnectable.html#GSocketAddressEnumerator">GSocketAddressEnumerator</a> * <a class="link" href="GSocketConnectable.html#g-socket-connectable-enumerate" title="g_socket_connectable_enumerate ()">g_socket_connectable_enumerate</a>
(<a class="link" href="GSocketConnectable.html" title="GSocketConnectable">GSocketConnectable</a> *connectable);
<a class="link" href="GSocketConnectable.html#GSocketAddressEnumerator-struct" title="GSocketAddressEnumerator">GSocketAddressEnumerator</a>;
<a class="link" href="GSocketAddress.html" title="GSocketAddress">GSocketAddress</a> * <a class="link" href="GSocketConnectable.html#g-socket-address-enumerator-next" title="g_socket_address_enumerator_next ()">g_socket_address_enumerator_next</a> (<a class="link" href="GSocketConnectable.html#GSocketAddressEnumerator">GSocketAddressEnumerator</a> *enumerator,
<a class="link" href="GCancellable.html" title="GCancellable">GCancellable</a> *cancellable,
<a
href="http://library.gnome.org/devel/glib/unstable/glib-Error-Reporting.html#GError"
>GError</a> **error);
void <a class="link" href="GSocketConnectable.html#g-socket-address-enumerator-next-async" title="g_socket_address_enumerator_next_async ()">g_socket_address_enumerator_next_async</a>
(<a class="link" href="GSocketConnectable.html#GSocketAddressEnumerator">GSocketAddressEnumerator</a> *enumerator,
<a class="link" href="GCancellable.html" title="GCancellable">GCancellable</a> *cancellable,
<a class="link" href="GAsyncResult.html#GAsyncReadyCallback" title="GAsyncReadyCallback ()">GAsyncReadyCallback</a> callback,
<a
href="http://library.gnome.org/devel/glib/unstable/glib-Basic-Types.html#gpointer"
>gpointer</a> user_data);
<a class="link" href="GSocketAddress.html" title="GSocketAddress">GSocketAddress</a> * <a class="link" href="GSocketConnectable.html#g-socket-address-enumerator-next-finish" title="g_socket_address_enumerator_next_finish ()">g_socket_address_enumerator_next_finish</a>
(<a class="link" href="GSocketConnectable.html#GSocketAddressEnumerator">GSocketAddressEnumerator</a> *enumerator,
<a class="link" href="GAsyncResult.html" title="GAsyncResult">GAsyncResult</a> *result,
<a
href="http://library.gnome.org/devel/glib/unstable/glib-Error-Reporting.html#GError"
>GError</a> **error);
</pre>
</div>
<div class="refsect1" title="Object Hierarchy">
<a name="GSocketConnectable.object-hierarchy"></a><h2>Object Hierarchy</h2>
<pre class="synopsis">
GInterface
+----GSocketConnectable
</pre>
<pre class="synopsis">
<a
href="http://library.gnome.org/devel/gobject/unstable/gobject-The-Base-Object-Type.html#GObject"
>GObject</a>
+----GSocketAddressEnumerator
</pre>
</div>
<div class="refsect1" title="Prerequisites">
<a name="GSocketConnectable.prerequisites"></a><h2>Prerequisites</h2>
<p>
GSocketConnectable requires
<a
href="http://library.gnome.org/devel/gobject/unstable/gobject-The-Base-Object-Type.html#GObject"
>GObject</a>.</p>
</div>
<div class="refsect1" title="Known Implementations">
<a name="GSocketConnectable.implementations"></a><h2>Known Implementations</h2>
<p>
GSocketConnectable is implemented by
<a class="link" href="GUnixSocketAddress.html" title="GUnixSocketAddress">GUnixSocketAddress</a>, <a class="link" href="GNetworkService.html" title="GNetworkService">GNetworkService</a>, <a class="link" href="GSocketAddress.html" title="GSocketAddress">GSocketAddress</a>, <a class="link" href="GNetworkAddress.html" title="GNetworkAddress">GNetworkAddress</a> and <a class="link" href="GInetSocketAddress.html" title="GInetSocketAddress">GInetSocketAddress</a>.</p>
</div>
<div class="refsect1" title="Description">
<a name="GSocketConnectable.description"></a><h2>Description</h2>
<p>
Objects that describe one or more potential socket endpoints
implement <a class="link" href="GSocketConnectable.html" title="GSocketConnectable"><span class="type">GSocketConnectable</span></a>. Callers can then use
<a class="link" href="GSocketConnectable.html#g-socket-connectable-enumerate" title="g_socket_connectable_enumerate ()"><code class="function">g_socket_connectable_enumerate()</code></a> to get a <a class="link" href="GSocketConnectable.html#GSocketAddressEnumerator"><span class="type">GSocketAddressEnumerator</span></a>
to try out each socket address in turn until one succeeds, as shown
in the sample code below.
</p>
<p>
</p>
<div class="informalexample"><pre class="programlisting">
MyConnectionType *
connect_to_host (const char *hostname,
guint16 port,
GCancellable *cancellable,
GError **error)
{
MyConnection *conn = NULL;
GSocketConnectable *addr;
GSocketAddressEnumerator *enumerator;
GSocketAddress *sockaddr;
GError *conn_error = NULL;
addr = g_network_address_new ("www.gnome.org", 80);
enumerator = g_socket_connectable_enumerate (addr);
g_object_unref (addr);
/* Try each sockaddr until we succeed. Record the first
* connection error, but not any further ones (since they'll probably
* be basically the same as the first).
*/
while (!conn && (sockaddr = g_socket_address_enumerator_next (enumerator, cancellable, error))
{
conn = connect_to_sockaddr (sockaddr, conn_error ? NULL : &conn_error);
g_object_unref (sockaddr);
}
g_object_unref (enumerator);
if (conn)
{
if (conn_error)
{
/* We couldn't connect to the first address, but we succeeded
* in connecting to a later address.
*/
g_error_free (conn_error);
}
return conn;
}
else if (error)
{
/* Either the initial lookup failed, or else the caller
* cancelled us.
*/
if (conn_error)
g_error_free (conn_error);
return NULL;
}
else
{
g_error_propagate (error, conn_error);
return NULL;
}
}
</pre></div>
<p>
</p>
</div>
<div class="refsect1" title="Details">
<a name="GSocketConnectable.details"></a><h2>Details</h2>
<div class="refsect2" title="GSocketConnectable">
<a name="GSocketConnectable-struct"></a><h3>GSocketConnectable</h3>
<pre class="programlisting">typedef struct _GSocketConnectable GSocketConnectable;</pre>
<p>
Interface for objects that contain or generate <a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a>es.</p>
<p>
</p>
</div>
<hr>
<div class="refsect2" title="GSocketConnectableIface">
<a name="GSocketConnectableIface"></a><h3>GSocketConnectableIface</h3>
<pre class="programlisting">typedef struct {
GTypeInterface g_iface;
/* Virtual Table */
GSocketAddressEnumerator * (* enumerate) (GSocketConnectable *connectable);
} GSocketConnectableIface;
</pre>
<p>
Provides an interface for returning a <a class="link" href="GSocketConnectable.html#GSocketAddressEnumerator"><span class="type">GSocketAddressEnumerator</span></a></p>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><a
href="http://library.gnome.org/devel/gobject/unstable/gobject-Type-Information.html#GTypeInterface"
>GTypeInterface</a> <em class="structfield"><code>g_iface</code></em>;</span></p></td>
<td> The parent interface.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="structfield"><code>enumerate</code></em> ()</span></p></td>
<td> Creates a <a class="link" href="GSocketConnectable.html#GSocketAddressEnumerator"><span class="type">GSocketAddressEnumerator</span></a>
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" title="g_socket_connectable_enumerate ()">
<a name="g-socket-connectable-enumerate"></a><h3>g_socket_connectable_enumerate ()</h3>
<pre class="programlisting"><a class="link" href="GSocketConnectable.html#GSocketAddressEnumerator">GSocketAddressEnumerator</a> * g_socket_connectable_enumerate
(<a class="link" href="GSocketConnectable.html" title="GSocketConnectable">GSocketConnectable</a> *connectable);</pre>
<p>
Creates a <a class="link" href="GSocketConnectable.html#GSocketAddressEnumerator"><span class="type">GSocketAddressEnumerator</span></a> for <em class="parameter"><code>connectable</code></em>.</p>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>connectable</code></em> :</span></p></td>
<td> a <a class="link" href="GSocketConnectable.html" title="GSocketConnectable"><span class="type">GSocketConnectable</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td> a new <a class="link" href="GSocketConnectable.html#GSocketAddressEnumerator"><span class="type">GSocketAddressEnumerator</span></a>.
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.22</p>
</div>
<hr>
<div class="refsect2" title="GSocketAddressEnumerator">
<a name="GSocketAddressEnumerator-struct"></a><h3>GSocketAddressEnumerator</h3>
<pre class="programlisting">typedef struct _GSocketAddressEnumerator GSocketAddressEnumerator;</pre>
<p>
Enumerator type for objects that contain or generate
<a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a>es.</p>
<p>
</p>
</div>
<hr>
<div class="refsect2" title="g_socket_address_enumerator_next ()">
<a name="g-socket-address-enumerator-next"></a><h3>g_socket_address_enumerator_next ()</h3>
<pre class="programlisting"><a class="link" href="GSocketAddress.html" title="GSocketAddress">GSocketAddress</a> * g_socket_address_enumerator_next (<a class="link" href="GSocketConnectable.html#GSocketAddressEnumerator">GSocketAddressEnumerator</a> *enumerator,
<a class="link" href="GCancellable.html" title="GCancellable">GCancellable</a> *cancellable,
<a
href="http://library.gnome.org/devel/glib/unstable/glib-Error-Reporting.html#GError"
>GError</a> **error);</pre>
<p>
Retrieves the next <a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a> from <em class="parameter"><code>enumerator</code></em>. Note that this
may block for some amount of time. (Eg, a <a class="link" href="GNetworkAddress.html" title="GNetworkAddress"><span class="type">GNetworkAddress</span></a> may need
to do a DNS lookup before it can return an address.) Use
<a class="link" href="GSocketConnectable.html#g-socket-address-enumerator-next-async" title="g_socket_address_enumerator_next_async ()"><code class="function">g_socket_address_enumerator_next_async()</code></a> if you need to avoid
blocking.
</p>
<p>
If <em class="parameter"><code>enumerator</code></em> is expected to yield addresses, but for some reason
is unable to (eg, because of a DNS error), then the first call to
<a class="link" href="GSocketConnectable.html#g-socket-address-enumerator-next" title="g_socket_address_enumerator_next ()"><code class="function">g_socket_address_enumerator_next()</code></a> will return an appropriate error
in *<em class="parameter"><code>error</code></em>. However, if the first call to
<a class="link" href="GSocketConnectable.html#g-socket-address-enumerator-next" title="g_socket_address_enumerator_next ()"><code class="function">g_socket_address_enumerator_next()</code></a> succeeds, then any further
internal errors (other than <em class="parameter"><code>cancellable</code></em> being triggered) will be
ignored.</p>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>enumerator</code></em> :</span></p></td>
<td> a <a class="link" href="GSocketConnectable.html#GSocketAddressEnumerator"><span class="type">GSocketAddressEnumerator</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>cancellable</code></em> :</span></p></td>
<td> optional <a class="link" href="GCancellable.html" title="GCancellable"><span class="type">GCancellable</span></a> object, <a
href="http://library.gnome.org/devel/glib/unstable/glib-Standard-Macros.html#NULL--CAPS"
><code class="literal">NULL</code></a> to ignore.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td>
<td> a <a
href="http://library.gnome.org/devel/glib/unstable/glib-Error-Reporting.html#GError"
><span class="type">GError</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td> a <a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a> (owned by the caller), or <a
href="http://library.gnome.org/devel/glib/unstable/glib-Standard-Macros.html#NULL--CAPS"
><code class="literal">NULL</code></a> on
error (in which case *<em class="parameter"><code>error</code></em> will be set) or if there are no
more addresses.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" title="g_socket_address_enumerator_next_async ()">
<a name="g-socket-address-enumerator-next-async"></a><h3>g_socket_address_enumerator_next_async ()</h3>
<pre class="programlisting">void g_socket_address_enumerator_next_async
(<a class="link" href="GSocketConnectable.html#GSocketAddressEnumerator">GSocketAddressEnumerator</a> *enumerator,
<a class="link" href="GCancellable.html" title="GCancellable">GCancellable</a> *cancellable,
<a class="link" href="GAsyncResult.html#GAsyncReadyCallback" title="GAsyncReadyCallback ()">GAsyncReadyCallback</a> callback,
<a
href="http://library.gnome.org/devel/glib/unstable/glib-Basic-Types.html#gpointer"
>gpointer</a> user_data);</pre>
<p>
Asynchronously retrieves the next <a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a> from <em class="parameter"><code>enumerator</code></em>
and then calls <em class="parameter"><code>callback</code></em>, which must call
<a class="link" href="GSocketConnectable.html#g-socket-address-enumerator-next-finish" title="g_socket_address_enumerator_next_finish ()"><code class="function">g_socket_address_enumerator_next_finish()</code></a> to get the result.</p>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>enumerator</code></em> :</span></p></td>
<td> a <a class="link" href="GSocketConnectable.html#GSocketAddressEnumerator"><span class="type">GSocketAddressEnumerator</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>cancellable</code></em> :</span></p></td>
<td> optional <a class="link" href="GCancellable.html" title="GCancellable"><span class="type">GCancellable</span></a> object, <a
href="http://library.gnome.org/devel/glib/unstable/glib-Standard-Macros.html#NULL--CAPS"
><code class="literal">NULL</code></a> to ignore.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>callback</code></em> :</span></p></td>
<td> a <a class="link" href="GAsyncResult.html#GAsyncReadyCallback" title="GAsyncReadyCallback ()"><span class="type">GAsyncReadyCallback</span></a> to call when the request is satisfied
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td>
<td> the data to pass to callback function
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" title="g_socket_address_enumerator_next_finish ()">
<a name="g-socket-address-enumerator-next-finish"></a><h3>g_socket_address_enumerator_next_finish ()</h3>
<pre class="programlisting"><a class="link" href="GSocketAddress.html" title="GSocketAddress">GSocketAddress</a> * g_socket_address_enumerator_next_finish
(<a class="link" href="GSocketConnectable.html#GSocketAddressEnumerator">GSocketAddressEnumerator</a> *enumerator,
<a class="link" href="GAsyncResult.html" title="GAsyncResult">GAsyncResult</a> *result,
<a
href="http://library.gnome.org/devel/glib/unstable/glib-Error-Reporting.html#GError"
>GError</a> **error);</pre>
<p>
Retrieves the result of a completed call to
<a class="link" href="GSocketConnectable.html#g-socket-address-enumerator-next-async" title="g_socket_address_enumerator_next_async ()"><code class="function">g_socket_address_enumerator_next_async()</code></a>. See
<a class="link" href="GSocketConnectable.html#g-socket-address-enumerator-next" title="g_socket_address_enumerator_next ()"><code class="function">g_socket_address_enumerator_next()</code></a> for more information about
error handling.</p>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>enumerator</code></em> :</span></p></td>
<td> a <a class="link" href="GSocketConnectable.html#GSocketAddressEnumerator"><span class="type">GSocketAddressEnumerator</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>result</code></em> :</span></p></td>
<td> a <a class="link" href="GAsyncResult.html" title="GAsyncResult"><span class="type">GAsyncResult</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td>
<td> a <a
href="http://library.gnome.org/devel/glib/unstable/glib-Error-Reporting.html#GError"
><span class="type">GError</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td> a <a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a> (owned by the caller), or <a
href="http://library.gnome.org/devel/glib/unstable/glib-Standard-Macros.html#NULL--CAPS"
><code class="literal">NULL</code></a> on
error (in which case *<em class="parameter"><code>error</code></em> will be set) or if there are no
more addresses.
</td>
</tr>
</tbody>
</table></div>
</div>
</div>
</div>
<div class="footer">
<hr>
Generated by GTK-Doc V1.11</div>
</body>
</html>