blob: 5d710343a94f19b732582fcf9ee9fd679dbfabff [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>GNetworkAddress</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="GSocketConnectable.html" title="GSocketConnectable">
<link rel="next" href="GNetworkService.html" title="GNetworkService">
<meta name="generator" content="GTK-Doc V1.14 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</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="GSocketConnectable.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="GNetworkService.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr>
<tr><td colspan="5" class="shortcuts">
<a href="#GNetworkAddress.synopsis" class="shortcut">Top</a>
 | 
<a href="#GNetworkAddress.description" class="shortcut">Description</a>
 | 
<a href="#GNetworkAddress.object-hierarchy" class="shortcut">Object Hierarchy</a>
 | 
<a href="#GNetworkAddress.implemented-interfaces" class="shortcut">Implemented Interfaces</a>
 | 
<a href="#GNetworkAddress.properties" class="shortcut">Properties</a>
</td></tr>
</table>
<div class="refentry" title="GNetworkAddress">
<a name="GNetworkAddress"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2><span class="refentrytitle"><a name="GNetworkAddress.top_of_page"></a>GNetworkAddress</span></h2>
<p>GNetworkAddress — A GSocketConnectable for resolving hostnames</p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsynopsisdiv" title="Synopsis">
<a name="GNetworkAddress.synopsis"></a><h2>Synopsis</h2>
<pre class="synopsis">
#include &lt;gio/gio.h&gt;
<a class="link" href="GNetworkAddress.html#GNetworkAddress-struct" title="GNetworkAddress">GNetworkAddress</a>;
<a class="link" href="GSocketConnectable.html" title="GSocketConnectable"><span class="returnvalue">GSocketConnectable</span></a> * <a class="link" href="GNetworkAddress.html#g-network-address-new" title="g_network_address_new ()">g_network_address_new</a> (<em class="parameter"><code>const <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *hostname</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint16"><span class="type">guint16</span></a> port</code></em>);
const <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar"><span class="returnvalue">gchar</span></a> * <a class="link" href="GNetworkAddress.html#g-network-address-get-hostname" title="g_network_address_get_hostname ()">g_network_address_get_hostname</a> (<em class="parameter"><code><a class="link" href="GNetworkAddress.html" title="GNetworkAddress"><span class="type">GNetworkAddress</span></a> *addr</code></em>);
<a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint16"><span class="returnvalue">guint16</span></a> <a class="link" href="GNetworkAddress.html#g-network-address-get-port" title="g_network_address_get_port ()">g_network_address_get_port</a> (<em class="parameter"><code><a class="link" href="GNetworkAddress.html" title="GNetworkAddress"><span class="type">GNetworkAddress</span></a> *addr</code></em>);
<a class="link" href="GSocketConnectable.html" title="GSocketConnectable"><span class="returnvalue">GSocketConnectable</span></a> * <a class="link" href="GNetworkAddress.html#g-network-address-parse" title="g_network_address_parse ()">g_network_address_parse</a> (<em class="parameter"><code>const <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *host_and_port</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint16"><span class="type">guint16</span></a> default_port</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);
</pre>
</div>
<div class="refsect1" title="Object Hierarchy">
<a name="GNetworkAddress.object-hierarchy"></a><h2>Object Hierarchy</h2>
<pre class="synopsis">
<a href="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#GObject">GObject</a>
+----GNetworkAddress
</pre>
</div>
<div class="refsect1" title="Implemented Interfaces">
<a name="GNetworkAddress.implemented-interfaces"></a><h2>Implemented Interfaces</h2>
<p>
GNetworkAddress implements
<a class="link" href="GSocketConnectable.html" title="GSocketConnectable">GSocketConnectable</a>.</p>
</div>
<div class="refsect1" title="Properties">
<a name="GNetworkAddress.properties"></a><h2>Properties</h2>
<pre class="synopsis">
"<a class="link" href="GNetworkAddress.html#GNetworkAddress--hostname" title='The "hostname" property'>hostname</a>" <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a>* : Read / Write / Construct Only
"<a class="link" href="GNetworkAddress.html#GNetworkAddress--port" title='The "port" property'>port</a>" <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint"><span class="type">guint</span></a> : Read / Write / Construct Only
</pre>
</div>
<div class="refsect1" title="Description">
<a name="GNetworkAddress.description"></a><h2>Description</h2>
<p>
<a class="link" href="GNetworkAddress.html" title="GNetworkAddress"><span class="type">GNetworkAddress</span></a> provides an easy way to resolve a hostname and
then attempt to connect to that host, handling the possibility of
multiple IP addresses and multiple address families.
</p>
<p>
See <a class="link" href="GSocketConnectable.html" title="GSocketConnectable"><span class="type">GSocketConnectable</span></a> for and example of using the connectable
interface.
</p>
</div>
<div class="refsect1" title="Details">
<a name="GNetworkAddress.details"></a><h2>Details</h2>
<div class="refsect2" title="GNetworkAddress">
<a name="GNetworkAddress-struct"></a><h3>GNetworkAddress</h3>
<pre class="programlisting">typedef struct _GNetworkAddress GNetworkAddress;</pre>
<p>
A <a class="link" href="GSocketConnectable.html" title="GSocketConnectable"><span class="type">GSocketConnectable</span></a> for resolving a hostname and connecting to
that host.
</p>
</div>
<hr>
<div class="refsect2" title="g_network_address_new ()">
<a name="g-network-address-new"></a><h3>g_network_address_new ()</h3>
<pre class="programlisting"><a class="link" href="GSocketConnectable.html" title="GSocketConnectable"><span class="returnvalue">GSocketConnectable</span></a> * g_network_address_new (<em class="parameter"><code>const <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *hostname</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint16"><span class="type">guint16</span></a> port</code></em>);</pre>
<p>
Creates a new <a class="link" href="GSocketConnectable.html" title="GSocketConnectable"><span class="type">GSocketConnectable</span></a> for connecting to the given
<em class="parameter"><code>hostname</code></em> and <em class="parameter"><code>port</code></em>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>hostname</code></em> :</span></p></td>
<td>the hostname
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>port</code></em> :</span></p></td>
<td>the port
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td> the new <a class="link" href="GNetworkAddress.html" title="GNetworkAddress"><span class="type">GNetworkAddress</span></a>
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.22</p>
</div>
<hr>
<div class="refsect2" title="g_network_address_get_hostname ()">
<a name="g-network-address-get-hostname"></a><h3>g_network_address_get_hostname ()</h3>
<pre class="programlisting">const <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar"><span class="returnvalue">gchar</span></a> * g_network_address_get_hostname (<em class="parameter"><code><a class="link" href="GNetworkAddress.html" title="GNetworkAddress"><span class="type">GNetworkAddress</span></a> *addr</code></em>);</pre>
<p>
Gets <em class="parameter"><code>addr</code></em>'s hostname. This might be either UTF-8 or ASCII-encoded,
depending on what <em class="parameter"><code>addr</code></em> was created with.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>addr</code></em> :</span></p></td>
<td>a <a class="link" href="GNetworkAddress.html" title="GNetworkAddress"><span class="type">GNetworkAddress</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td> <em class="parameter"><code>addr</code></em>'s hostname
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.22</p>
</div>
<hr>
<div class="refsect2" title="g_network_address_get_port ()">
<a name="g-network-address-get-port"></a><h3>g_network_address_get_port ()</h3>
<pre class="programlisting"><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint16"><span class="returnvalue">guint16</span></a> g_network_address_get_port (<em class="parameter"><code><a class="link" href="GNetworkAddress.html" title="GNetworkAddress"><span class="type">GNetworkAddress</span></a> *addr</code></em>);</pre>
<p>
Gets <em class="parameter"><code>addr</code></em>'s port number
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>addr</code></em> :</span></p></td>
<td>a <a class="link" href="GNetworkAddress.html" title="GNetworkAddress"><span class="type">GNetworkAddress</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td> <em class="parameter"><code>addr</code></em>'s port (which may be 0)
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.22</p>
</div>
<hr>
<div class="refsect2" title="g_network_address_parse ()">
<a name="g-network-address-parse"></a><h3>g_network_address_parse ()</h3>
<pre class="programlisting"><a class="link" href="GSocketConnectable.html" title="GSocketConnectable"><span class="returnvalue">GSocketConnectable</span></a> * g_network_address_parse (<em class="parameter"><code>const <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *host_and_port</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint16"><span class="type">guint16</span></a> default_port</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);</pre>
<p>
Creates a new <a class="link" href="GSocketConnectable.html" title="GSocketConnectable"><span class="type">GSocketConnectable</span></a> for connecting to the given
<em class="parameter"><code>hostname</code></em> and <em class="parameter"><code>port</code></em>. May fail and return <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> in case
parsing <em class="parameter"><code>host_and_port</code></em> fails.
</p>
<p>
<em class="parameter"><code>host_and_port</code></em> may be in any of a number of recognised formats: an IPv6
address, an IPv4 address, or a domain name (in which case a DNS
lookup is performed). Quoting with [] is supported for all address
types. A port override may be specified in the usual way with a
colon. Ports may be given as decimal numbers or symbolic names (in
which case an /etc/services lookup is performed).
</p>
<p>
If no port is specified in <em class="parameter"><code>host_and_port</code></em> then <em class="parameter"><code>default_port</code></em> will be
used as the port number to connect to.
</p>
<p>
In general, <em class="parameter"><code>host_and_port</code></em> is expected to be provided by the user
(allowing them to give the hostname, and a port overide if necessary)
and <em class="parameter"><code>default_port</code></em> is expected to be provided by the application.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>host_and_port</code></em> :</span></p></td>
<td>the hostname and optionally a port
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>default_port</code></em> :</span></p></td>
<td>the default port if not in <em class="parameter"><code>host_and_port</code></em>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td>
<td>a pointer to a <a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a>, or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td> the new <a class="link" href="GNetworkAddress.html" title="GNetworkAddress"><span class="type">GNetworkAddress</span></a>, or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> on error
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.22</p>
</div>
</div>
<div class="refsect1" title="Property Details">
<a name="GNetworkAddress.property-details"></a><h2>Property Details</h2>
<div class="refsect2" title='The "hostname" property'>
<a name="GNetworkAddress--hostname"></a><h3>The <code class="literal">"hostname"</code> property</h3>
<pre class="programlisting"> "hostname" <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a>* : Read / Write / Construct Only</pre>
<p>Hostname to resolve.</p>
<p>Default value: NULL</p>
</div>
<hr>
<div class="refsect2" title='The "port" property'>
<a name="GNetworkAddress--port"></a><h3>The <code class="literal">"port"</code> property</h3>
<pre class="programlisting"> "port" <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint"><span class="type">guint</span></a> : Read / Write / Construct Only</pre>
<p>Network port.</p>
<p>Allowed values: &lt;= 65535</p>
<p>Default value: 0</p>
</div>
</div>
</div>
<div class="footer">
<hr>
Generated by GTK-Doc V1.14</div>
</body>
</html>