Symbian3/SDK/Source/GUID-182A7A60-80BD-5E54-917A-8F4C26BB94CB.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Tue, 20 Jul 2010 12:00:49 +0100
changeset 13 48780e181b38
parent 0 89d6a7a84779
permissions -rw-r--r--
Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License 
"Eclipse Public License v1.0" which accompanies this distribution, 
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
    Nokia Corporation - initial contribution.
Contributors: 
-->
<!DOCTYPE concept
  PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept id="GUID-182A7A60-80BD-5E54-917A-8F4C26BB94CB" xml:lang="en"><title> Connecting
and Disconnecting a Remote Host Tutorial</title><shortdesc>This topic describes how to connect and disconnect a remote host. </shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>

<section><title>Introduction</title><p>To send and receive the data packets,
a connection must be established with a remote host. This tutorial describes
the following: </p><ul>
<li><p> <xref href="GUID-182A7A60-80BD-5E54-917A-8F4C26BB94CB.dita#GUID-182A7A60-80BD-5E54-917A-8F4C26BB94CB/GUID-E832AD84-7441-5AC2-9884-AAC0C736CCBE">How
to Connect to a Remote Host</xref>  </p> </li>
<li><p>  <xref href="GUID-182A7A60-80BD-5E54-917A-8F4C26BB94CB.dita#GUID-182A7A60-80BD-5E54-917A-8F4C26BB94CB/GUID-A1FD6397-0110-50FE-89E2-CB0734FD5D22">How
to Disconnect from a Remote Host</xref>  </p> </li>
<li><p>  <xref href="GUID-182A7A60-80BD-5E54-917A-8F4C26BB94CB.dita#GUID-182A7A60-80BD-5E54-917A-8F4C26BB94CB/GUID-D1876052-357C-5D1B-AC2D-23536CC60FF6">How
to Listen to a Connect Request</xref> </p> </li>
<li><p>  <xref href="GUID-182A7A60-80BD-5E54-917A-8F4C26BB94CB.dita#GUID-182A7A60-80BD-5E54-917A-8F4C26BB94CB/GUID-90E124C2-4B2C-51FE-AF07-923853C617B7">How
to Accept a Connect Request</xref>  </p> </li>
<li><p>  <xref href="GUID-182A7A60-80BD-5E54-917A-8F4C26BB94CB.dita#GUID-182A7A60-80BD-5E54-917A-8F4C26BB94CB/GUID-7727C0A0-5D80-5325-991E-0BA627B1356C">How
to Shut down a Connection</xref>  </p> </li>
</ul> </section>
<section><title>How
to Connect to a Remote Host</title><p>The high level steps to connect to a
remote host are as follows:</p> <ol id="GUID-46E4E5C3-E121-5B53-8E52-E00C6FE664AB">
<li id="GUID-84078269-543D-533E-B0C8-F571AFD0B049"><p>The <xref href="GUID-D4F08503-F1EF-3531-9C3C-4AF24A6255F0.dita#GUID-D4F08503-F1EF-3531-9C3C-4AF24A6255F0/GUID-AC5A49E9-337D-334A-9CD0-DB8226372306"><apiname>RSocket::Connect()</apiname></xref> function
connects to a remote host. The <codeph>RSocket::Connect()</codeph> parameters
identifies the required type of socket connection. For more information, see <xref href="GUID-B8DEA3EE-7BA7-5A29-9A27-B87EE0EB254F.dita#GUID-B8DEA3EE-7BA7-5A29-9A27-B87EE0EB254F/GUID-EB1C5A5A-E40C-559B-82E9-D19F8E4F4B49">important
parameters</xref> . </p> <p>For TCP sockets </p> <ol id="GUID-FCF6E01D-A632-595C-A79C-A17D13A9EE63">
<li id="GUID-D10BD1B0-549C-5766-B81E-D5B88B2C9F9F"><p>An active connection
is made to the remote host. When the socket call completes successfully, the
socket can send and receive data. To create a connection, the protocol must
establish a network interface and a route to the destination. For more information
about this process and return values, see the <xref href="GUID-D4F08503-F1EF-3531-9C3C-4AF24A6255F0.dita#GUID-D4F08503-F1EF-3531-9C3C-4AF24A6255F0/GUID-AC5A49E9-337D-334A-9CD0-DB8226372306"><apiname>RSocket::Connect()</apiname></xref> function. </p> </li>
</ol> </li>
<li id="GUID-37CC6747-BC8D-5C6E-8358-4EEEB5BC90C8"><p>For UDP </p> <ol id="GUID-1D9019A5-43C9-5D62-ABBC-8589472D24A1">
<li id="GUID-54B60EA0-F3B1-5261-B795-E67A8D616C93"><p>UDP is a connectionless
protocol which means the <codeph>RSocket::Connect()</codeph> does not have
to be called before writing data with <codeph>RSocket::SendTo()</codeph>.
It can be used to set the address for all data sent from the socket. In this
case, <codeph>Send()/Write()</codeph> function can be used in addition to <codeph>SendTo()</codeph> function. </p> </li>
</ol> </li>
</ol><title>How to Disconnect from a Remote Host</title><p> For cancelling
the connection  </p><p> The <codeph>RSocket::CancelConnect()</codeph> function
cancels the outstanding connect operation with a remote host. This function
also cancels any outstanding <codeph>RSocket::Ioctl()</codeph> calls. After
this call, a socket can be reconnected by <codeph>RSocket::Connect()</codeph> function.
 </p><title>How to Listen to a Connect Request</title><p> A TCP socket can
be set to listen with <codeph>RSocket::Listen()</codeph>. The <codeph>aDataOut</codeph> argument
is ignored.  </p><title>How to Accept a Connect Request</title><p> A connection
request to a listening socket can be accepted with <codeph>RSocket::Accept()</codeph>.
An <codeph>aConnectData</codeph> argument cannot be specified.  </p><title>How
to Shut down a Connection</title><p> Use <codeph>RSocket::Shutdown()</codeph> to
asynchronously shut down a TCP. Disconnection data is not supported.  </p><p> The
following table describes the effects of different types of shut down for
TCP:  </p><table id="GUID-278A0CA9-6C8E-4909-9D69-4535C025C51D">
<tgroup cols="2"><colspec colname="col1"/><colspec colname="col2"/>
<tbody>
<row>
<entry><b>Type</b></entry>
<entry><b>Action</b></entry>
</row>
<row>
<entry><codeph>ENormal</codeph></entry>
<entry>Blocked reads and writes are terminated. No further data is accepted
from the remote source and TCP disconnect is initiated. </entry>
</row>
<row>
<entry><codeph>EStopInput</codeph></entry>
<entry>Blocked reads are terminated. No further data is accepted from the
remote source.</entry>
</row>
<row>
<entry><codeph>EStopOutput</codeph></entry>
<entry>Blocked writes are terminated. TCP disconnect is initiated.</entry>
</row>
<row>
<entry><codeph>Eimmediate</codeph></entry>
<entry>Blocked reads and writes are terminated. The connection is terminated
by sending a reset.</entry>
</row>
</tbody>
</tgroup>
</table> </section>
</conbody></concept>