Symbian3/PDK/Source/GUID-3AB8E95D-4270-5CDE-994E-404BCBEC57B6.dita
changeset 1 25a17d01db0c
child 3 46218c8b8afa
equal deleted inserted replaced
0:89d6a7a84779 1:25a17d01db0c
       
     1 <?xml version="1.0" encoding="utf-8"?>
       
     2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
       
     3 <!-- This component and the accompanying materials are made available under the terms of the License 
       
     4 "Eclipse Public License v1.0" which accompanies this distribution, 
       
     5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
       
     6 <!-- Initial Contributors:
       
     7     Nokia Corporation - initial contribution.
       
     8 Contributors: 
       
     9 -->
       
    10 <!DOCTYPE concept
       
    11   PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
       
    12 <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;
       
    13 RConnection conn;
       
    14 RSubConnection subconn;
       
    15 RSocket sock;
       
    16 TRequestStatus status;
       
    17 
       
    18 // Connect to ESOCK
       
    19 ss.Connect();
       
    20 
       
    21 // Open an Connection
       
    22 conn.Open(ss, KAfInet);
       
    23 
       
    24 // Start the connection
       
    25 conn.Start(status);
       
    26 User::WaitForRequest(status);
       
    27 
       
    28 // Attach to the default sub-connection
       
    29 subconn.Open(ss, RSubConnection::EAttachToDefault, conn);
       
    30 
       
    31 // Set Properties of the default sub-connection
       
    32 subconn.SetParameters(…);
       
    33 
       
    34 // Open a TCP socket on the connection (this is the same as using the default sub-connection)
       
    35 sock.Open(ss, KAfInet, KSockStream, KProtocolInetTcp, conn);
       
    36 
       
    37 _LIT(KRasAddr,"10.159.24.13");
       
    38 const TInt KEchoPort = 7;
       
    39 
       
    40 TInetAddr destAddr;
       
    41 destAddr.Input(KRasAddr);
       
    42 destAddr.SetPort(KEchoPort);
       
    43 
       
    44 // Request the Socket to connect to the destination over the default sub-connection
       
    45 sock.Connect(destAddr, status);
       
    46 </codeblock> <p> <b>Note:</b> Error handling is not included to aid clarity. </p> </conbody></concept>