Symbian3/SDK/Source/GUID-722180B8-0032-5C3F-AEB2-A9B1261450D8.dita
changeset 7 51a74ef9ed63
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Symbian3/SDK/Source/GUID-722180B8-0032-5C3F-AEB2-A9B1261450D8.dita	Wed Mar 31 11:11:55 2010 +0100
@@ -0,0 +1,84 @@
+<?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 task
+  PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
+<task id="GUID-722180B8-0032-5C3F-AEB2-A9B1261450D8" xml:lang="en"><title> Starting
+a Socket Server connection: Tutorial</title><shortdesc>This tutorial describes how to start an <codeph>RConnection</codeph> connection.
+Each connection must be started to link the connection with the network interface
+hardware. </shortdesc><prolog><metadata><keywords/></metadata></prolog><taskbody>
+<context id="GUID-62356291-EB29-4139-93A9-CB0F8F81F078"><p><b>Implicit Connection Startup</b></p><p>In the following example,
+the application is unaware of the connection and does not have an instance
+of <xref href="GUID-BED8A733-2ED7-31AD-A911-C1F4707C67FD.dita"><apiname>RConnection</apiname></xref>. This might be used if an application tries
+to connect a socket or resolve a name and the socket server detects that a
+connection has not been started. This example does not differ from previous
+versions of the Symbian platform.</p><p>Note: Error handling is not included
+to aid clarity.  </p><codeblock xml:space="preserve">RSocketServ ss;
+RSocket sock;
+TRequestStatus status;
+
+// Connect to the socket server
+ss.Connect();
+
+// Open a TCP socket 
+sock.Open(ss, KAfInet, KSockStream, KProtocolInetTcp);
+_LIT(KRasAddr,"10.159.24.13");
+const TInt KEchoPort = 7;
+TInetAddr destAddr;
+destAddr.Input(KRasAddr);
+destAddr.SetPort(KEchoPort);
+
+// Request the Socket to connect to the destination (implicit Connection)
+sock.Connect(destAddr, status);
+</codeblock></context>
+<example><title>Explicit Connection Startup</title> <p>The following example
+shows how an application can start a connection explicitly via an <codeph>RConnection</codeph> instance,
+and tie an <codeph>RHostResolver</codeph> and <codeph>RSocket</codeph> to
+the connection started. </p> <p>The application is able to override the connection
+preference settings in CommDb allowing it to specify the Network, IAP, ISP
+and bearer used. Code examples are given for the cases with and without overrides. </p> <p>See <xref href="GUID-739117F6-9559-3274-8E00-B2B653C0A8B6.dita"><apiname>TCommDbConnPref</apiname></xref> for
+information about how to set up the connection. </p> <codeblock id="GUID-1B9252B9-B731-55A0-A379-E51D94ACF768" xml:space="preserve">
+RSocketServ ss;
+TRequestStatus status;
+RConnection conn;
+
+_LIT(KRasAddr,"10.159.24.13");
+const TInt KEchoPort = 7;
+
+TInetAddr destAddr;
+destAddr.Input(KRasAddr);
+destAddr.SetPort(KEchoPort);
+
+// Connect to the socket server
+ss.Connect();
+
+// Open an RConnection object. Note that you must provide the RSocketServ object
+conn.Open(ss);
+
+// Create overrides
+TCommDbConnPref prefs;
+prefs. SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
+prefs.SetDirection(ECommDbConnectionDirectionOutgoing);
+prefs.SetIapId(4);
+
+// Start an Outgoing Connection with overrides
+conn.Start(prefs);
+
+// Open a Host Resolver associated with the connection
+RHostResolver hr;
+hr.Open(ss, KAfInet, KProtocolInetTcp, conn);
+
+// Open a Socket associated with the connection
+RSocket sock;
+sock.Open(ss, KAfInet, KSockStream, KProtocolInetTcp, conn);
+
+// Request the Socket to connect to the destination
+sock.Connect(destAddr, status);
+</codeblock> </example>
+</taskbody></task>
\ No newline at end of file