Symbian3/SDK/Source/GUID-3AB8E95D-4270-5CDE-994E-404BCBEC57B6.dita
changeset 0 89d6a7a84779
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Symbian3/SDK/Source/GUID-3AB8E95D-4270-5CDE-994E-404BCBEC57B6.dita	Thu Jan 21 18:18:20 2010 +0000
@@ -0,0 +1,46 @@
+<?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 xml:lang="en" id="GUID-3AB8E95D-4270-5CDE-994E-404BCBEC57B6"><title> Attaching to the default sub-connection: Tutorial</title><prolog><metadata><keywords/></metadata></prolog><conbody><p>This tutorial describes how an application can use the <xref href="GUID-0AFDA357-EE44-3788-9CAB-162B874134BF.dita"><apiname>RSubConnection</apiname></xref> API to attach to the default sub-connection. </p> <p>In the following example, the application wants to connect to the default sub-connection to set its properties. The application simply tries to connect a socket over the connection (which uses the default sub-connection) after it has set properties on the default sub-connection. An example of parameter creation can be found in the separate tutorial <xref href="GUID-7FAE6FE0-D5CB-55D4-94B0-ADD545577CA7.dita">Creating and setting properties for a Sub-Connection</xref>. </p> <codeblock id="GUID-E57DB0E4-D23D-55E4-A7C5-83C15BDA0E43" xml:space="preserve">RSocketServ ss;
+RConnection conn;
+RSubConnection subconn;
+RSocket sock;
+TRequestStatus status;
+
+// Connect to ESOCK
+ss.Connect();
+
+// Open an Connection
+conn.Open(ss, KAfInet);
+
+// Start the connection
+conn.Start(status);
+User::WaitForRequest(status);
+
+// Attach to the default sub-connection
+subconn.Open(ss, RSubConnection::EAttachToDefault, conn);
+
+// Set Properties of the default sub-connection
+subconn.SetParameters(…);
+
+// Open a TCP socket on the connection (this is the same as using the default sub-connection)
+sock.Open(ss, KAfInet, KSockStream, KProtocolInetTcp, conn);
+
+_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 over the default sub-connection
+sock.Connect(destAddr, status);
+</codeblock> <p> <b>Note:</b> Error handling is not included to aid clarity. </p> </conbody></concept>
\ No newline at end of file