<refentry id="gnome-vfs-20-gnome-vfs-inet-connection">
<refmeta>
<refentrytitle id="top_of_page">Internet connection</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>GNOME-VFS-2.0 Library</refmiscinfo>
</refmeta>

<refnamediv>
<refname>Internet connection</refname>
<refpurpose>Simple TCP/IP connection functions.</refpurpose>
<!--[<xref linkend="desc" endterm="desc.title"/>]-->
</refnamediv>

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

<synopsis>



<link linkend="GnomeVFSResult">GnomeVFSResult</link> <link linkend="gnome-vfs-inet-connection-create">gnome_vfs_inet_connection_create</link>
                                            (<link linkend="GnomeVFSInetConnection">GnomeVFSInetConnection</link> **connection_return,
                                             const <link linkend="gchar">gchar</link> *host_name,
                                             <link linkend="guint">guint</link> host_port,
                                             <link linkend="GnomeVFSCancellation">GnomeVFSCancellation</link> *cancellation);
<link linkend="void">void</link>        <link linkend="gnome-vfs-inet-connection-destroy">gnome_vfs_inet_connection_destroy</link>
                                            (<link linkend="GnomeVFSInetConnection">GnomeVFSInetConnection</link> *connection,
                                             <link linkend="GnomeVFSCancellation">GnomeVFSCancellation</link> *cancellation);
<link linkend="void">void</link>        <link linkend="gnome-vfs-inet-connection-free">gnome_vfs_inet_connection_free</link>  (<link linkend="GnomeVFSInetConnection">GnomeVFSInetConnection</link> *connection,
                                             <link linkend="GnomeVFSCancellation">GnomeVFSCancellation</link> *cancellation);
<link linkend="GnomeVFSSocket">GnomeVFSSocket</link>* <link linkend="gnome-vfs-inet-connection-to-socket">gnome_vfs_inet_connection_to_socket</link>
                                            (<link linkend="GnomeVFSInetConnection">GnomeVFSInetConnection</link> *connection);
<link linkend="GnomeVFSSocketBuffer">GnomeVFSSocketBuffer</link>* <link linkend="gnome-vfs-inet-connection-to-socket-buffer">gnome_vfs_inet_connection_to_socket_buffer</link>
                                            (<link linkend="GnomeVFSInetConnection">GnomeVFSInetConnection</link> *connection);
<link linkend="int">int</link>         <link linkend="gnome-vfs-inet-connection-get-fd">gnome_vfs_inet_connection_get_fd</link>
                                            (<link linkend="GnomeVFSInetConnection">GnomeVFSInetConnection</link> *connection);
<link linkend="GnomeVFSResult">GnomeVFSResult</link> <link linkend="gnome-vfs-inet-connection-create-from-address">gnome_vfs_inet_connection_create_from_address</link>
                                            (<link linkend="GnomeVFSInetConnection">GnomeVFSInetConnection</link> **connection_return,
                                             <link linkend="GnomeVFSAddress">GnomeVFSAddress</link> *address,
                                             <link linkend="guint">guint</link> host_port,
                                             <link linkend="GnomeVFSCancellation">GnomeVFSCancellation</link> *cancellation);
<link linkend="GnomeVFSAddress">GnomeVFSAddress</link>* <link linkend="gnome-vfs-inet-connection-get-address">gnome_vfs_inet_connection_get_address</link>
                                            (<link linkend="GnomeVFSInetConnection">GnomeVFSInetConnection</link> *connection);
<link linkend="char">char</link>*       <link linkend="gnome-vfs-inet-connection-get-ip">gnome_vfs_inet_connection_get_ip</link>
                                            (<link linkend="GnomeVFSInetConnection">GnomeVFSInetConnection</link> *connection);
</synopsis>
</refsynopsisdiv>









<refsect1 id="desc">
<title id="desc.title">Description</title>
<para>
A <link linkend="GnomeVFSInetConnection"><type>GnomeVFSInetConnection</type></link> represents a TCP/IP connection. You can either use
<link linkend="gnome-vfs-inet-connection-create"><type>gnome_vfs_inet_connection_create</type></link> which will use the <link linkend="gnome-vfs-resolve"><type>gnome_vfs_resolve</type></link> DNS
resolution functions internally or you can do the name resolution yourself
and use <link linkend="gnome-vfs-inet-connection-create-from-address"><type>gnome_vfs_inet_connection_create_from_address</type></link> to connect to a specific
address.

After a connection has been established all I/O is done through a GnomeVFSSocket
or a GnomeVFSSocketBuffer.

</para>
</refsect1>

<refsect1 id="details">
<title id="details.title">Details</title>
<refsect2>
<title><anchor id="gnome-vfs-inet-connection-create" role="function"/>gnome_vfs_inet_connection_create ()</title>
<indexterm><primary>gnome_vfs_inet_connection_create</primary></indexterm><programlisting><link linkend="GnomeVFSResult">GnomeVFSResult</link> gnome_vfs_inet_connection_create
                                            (<link linkend="GnomeVFSInetConnection">GnomeVFSInetConnection</link> **connection_return,
                                             const <link linkend="gchar">gchar</link> *host_name,
                                             <link linkend="guint">guint</link> host_port,
                                             <link linkend="GnomeVFSCancellation">GnomeVFSCancellation</link> *cancellation);</programlisting>
<para>
Creates a connection at <parameter>connection_return</parameter> to <parameter>host_name</parameter> using
port <parameter>port</parameter>.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>connection_return</parameter>&nbsp;:</term>
<listitem><simpara> pointer to a pointer to a <link linkend="GnomeVFSInetConnection"><type>GnomeVFSInetConnection</type></link>, which will
contain an allocated <link linkend="GnomeVFSInetConnection"><type>GnomeVFSInetConnection</type></link> object on return.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>host_name</parameter>&nbsp;:</term>
<listitem><simpara> string indicating the host to establish an internet connection with.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>host_port</parameter>&nbsp;:</term>
<listitem><simpara> port number to connect to.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>cancellation</parameter>&nbsp;:</term>
<listitem><simpara> handle allowing cancellation of the operation.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> <link linkend="GnomeVFSResult"><type>GnomeVFSResult</type></link> indicating the success of the operation.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="gnome-vfs-inet-connection-destroy" role="function"/>gnome_vfs_inet_connection_destroy ()</title>
<indexterm><primary>gnome_vfs_inet_connection_destroy</primary></indexterm><programlisting><link linkend="void">void</link>        gnome_vfs_inet_connection_destroy
                                            (<link linkend="GnomeVFSInetConnection">GnomeVFSInetConnection</link> *connection,
                                             <link linkend="GnomeVFSCancellation">GnomeVFSCancellation</link> *cancellation);</programlisting>
<para>
Closes/Destroys <parameter>connection</parameter>.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>connection</parameter>&nbsp;:</term>
<listitem><simpara> connection to destroy.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>cancellation</parameter>&nbsp;:</term>
<listitem><simpara> handle for cancelling the operation.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="gnome-vfs-inet-connection-free" role="function"/>gnome_vfs_inet_connection_free ()</title>
<indexterm><primary>gnome_vfs_inet_connection_free</primary></indexterm><programlisting><link linkend="void">void</link>        gnome_vfs_inet_connection_free  (<link linkend="GnomeVFSInetConnection">GnomeVFSInetConnection</link> *connection,
                                             <link linkend="GnomeVFSCancellation">GnomeVFSCancellation</link> *cancellation);</programlisting>
<para>
Frees <parameter>connection</parameter> without closing the socket.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>connection</parameter>&nbsp;:</term>
<listitem><simpara> connection to free.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>cancellation</parameter>&nbsp;:</term>
<listitem><simpara> handle for cancelling the operation.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="gnome-vfs-inet-connection-to-socket" role="function"/>gnome_vfs_inet_connection_to_socket ()</title>
<indexterm><primary>gnome_vfs_inet_connection_to_socket</primary></indexterm><programlisting><link linkend="GnomeVFSSocket">GnomeVFSSocket</link>* gnome_vfs_inet_connection_to_socket
                                            (<link linkend="GnomeVFSInetConnection">GnomeVFSInetConnection</link> *connection);</programlisting>
<para>
Wrap <parameter>connection</parameter> inside a standard <link linkend="GnomeVFSSocket"><type>GnomeVFSSocket</type></link> for convenience.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>connection</parameter>&nbsp;:</term>
<listitem><simpara> connection to be wrapped into a <link linkend="GnomeVFSSocket"><type>GnomeVFSSocket</type></link>.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> a newly created <link linkend="GnomeVFSSocket"><type>GnomeVFSSocket</type></link> around <parameter>connection</parameter>.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="gnome-vfs-inet-connection-to-socket-buffer" role="function"/>gnome_vfs_inet_connection_to_socket_buffer ()</title>
<indexterm><primary>gnome_vfs_inet_connection_to_socket_buffer</primary></indexterm><programlisting><link linkend="GnomeVFSSocketBuffer">GnomeVFSSocketBuffer</link>* gnome_vfs_inet_connection_to_socket_buffer
                                            (<link linkend="GnomeVFSInetConnection">GnomeVFSInetConnection</link> *connection);</programlisting>
<para>
Wrap <parameter>connection</parameter> inside a standard <link linkend="GnomeVFSSocketBuffer"><type>GnomeVFSSocketBuffer</type></link> for convenience.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>connection</parameter>&nbsp;:</term>
<listitem><simpara> connection to be wrapped into a <link linkend="GnomeVFSSocketBuffer"><type>GnomeVFSSocketBuffer</type></link>.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> a newly created <link linkend="GnomeVFSSocketBuffer"><type>GnomeVFSSocketBuffer</type></link> around <parameter>connection</parameter>.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="gnome-vfs-inet-connection-get-fd" role="function"/>gnome_vfs_inet_connection_get_fd ()</title>
<indexterm><primary>gnome_vfs_inet_connection_get_fd</primary></indexterm><programlisting><link linkend="int">int</link>         gnome_vfs_inet_connection_get_fd
                                            (<link linkend="GnomeVFSInetConnection">GnomeVFSInetConnection</link> *connection);</programlisting>
<para>
Retrieve the UNIX file descriptor corresponding to <parameter>connection</parameter>.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>connection</parameter>&nbsp;:</term>
<listitem><simpara> connection to get the file descriptor from.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> file descriptor.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="gnome-vfs-inet-connection-create-from-address" role="function" condition="since:2.8"/>gnome_vfs_inet_connection_create_from_address ()</title>
<indexterm role="2.8"><primary>gnome_vfs_inet_connection_create_from_address</primary></indexterm><programlisting><link linkend="GnomeVFSResult">GnomeVFSResult</link> gnome_vfs_inet_connection_create_from_address
                                            (<link linkend="GnomeVFSInetConnection">GnomeVFSInetConnection</link> **connection_return,
                                             <link linkend="GnomeVFSAddress">GnomeVFSAddress</link> *address,
                                             <link linkend="guint">guint</link> host_port,
                                             <link linkend="GnomeVFSCancellation">GnomeVFSCancellation</link> *cancellation);</programlisting>
<para>
Creates a connection at <parameter>connection_return</parameter> to <parameter>address</parameter> using
port <parameter>port</parameter>.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>connection_return</parameter>&nbsp;:</term>
<listitem><simpara> pointer to a pointer to a <link linkend="GnomeVFSInetConnection"><type>GnomeVFSInetConnection</type></link>, which will 
contain an allocated <link linkend="GnomeVFSInetConnection"><type>GnomeVFSInetConnection</type></link> object on return.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>address</parameter>&nbsp;:</term>
<listitem><simpara> a valid <link linkend="GnomeVFSAddress"><type>GnomeVFSAddress</type></link>.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>host_port</parameter>&nbsp;:</term>
<listitem><simpara> port number to connect to.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>cancellation</parameter>&nbsp;:</term>
<listitem><simpara> handle allowing cancellation of the operation.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> <link linkend="GnomeVFSResult"><type>GnomeVFSResult</type></link> indicating the success of the operation.

</simpara></listitem></varlistentry>
</variablelist><para>Since  2.8
</para></refsect2>
<refsect2>
<title><anchor id="gnome-vfs-inet-connection-get-address" role="function"/>gnome_vfs_inet_connection_get_address ()</title>
<indexterm><primary>gnome_vfs_inet_connection_get_address</primary></indexterm><programlisting><link linkend="GnomeVFSAddress">GnomeVFSAddress</link>* gnome_vfs_inet_connection_get_address
                                            (<link linkend="GnomeVFSInetConnection">GnomeVFSInetConnection</link> *connection);</programlisting>
<para>
Retrieve the address of the other side of a connected <parameter>connection</parameter>.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>connection</parameter>&nbsp;:</term>
<listitem><simpara> connection to get the address from. 
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> a <link linkend="GnomeVFSAddress"><type>GnomeVFSAddress</type></link> containing the address.

Since 2.8
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="gnome-vfs-inet-connection-get-ip" role="function" condition="since:2.8"/>gnome_vfs_inet_connection_get_ip ()</title>
<indexterm role="2.8"><primary>gnome_vfs_inet_connection_get_ip</primary></indexterm><programlisting><link linkend="char">char</link>*       gnome_vfs_inet_connection_get_ip
                                            (<link linkend="GnomeVFSInetConnection">GnomeVFSInetConnection</link> *connection);</programlisting>
<para>
Retrieve the ip address of the other side of a connected <parameter>connection</parameter>.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>connection</parameter>&nbsp;:</term>
<listitem><simpara> connection to get the ip from.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> string version of the ip.

</simpara></listitem></varlistentry>
</variablelist><para>Since  2.8
</para></refsect2>

</refsect1>




</refentry>
