|
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 id="GUID-8E158109-AE22-5216-90E8-63A4BD4CC90B" xml:lang="en"><title> Opening |
|
13 a Socket Server connection: Tutorial</title><shortdesc>This tutorial describes how an application can open and manage |
|
14 a connection to the Socket Server. Other Socket Server tutorials build upon |
|
15 this tutorial. The Socket Server is also known as ESock. </shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody> |
|
16 <section><title>Connecting to the Socket Server</title><p>The <xref href="GUID-EF29C1D7-B1E5-370F-AE37-66231A6BE449.dita"><apiname>RSocketServ</apiname></xref> class |
|
17 provides the <xref href="GUID-408D4D7E-FCD1-3ECF-AD62-6DA52E9580F5.dita"><apiname>Connect()</apiname></xref> function to create a session to |
|
18 the socket server. </p></section> |
|
19 <section><title>Procedure</title><p>The steps to connect and then close a |
|
20 session with the Socket Server are: </p><ul> |
|
21 <li><p> Call one of the <xref href="GUID-EF29C1D7-B1E5-370F-AE37-66231A6BE449.dita#GUID-EF29C1D7-B1E5-370F-AE37-66231A6BE449/GUID-C9E237C5-DCFB-3F66-87E5-63425156995C"><apiname>RSocketServ::Connect()</apiname></xref> functions. |
|
22 </p> </li> |
|
23 <li><p> Perform socket operations </p> </li> |
|
24 <li><p> Call <codeph>Close</codeph> to end the session with the Socket Server |
|
25 </p> </li> |
|
26 </ul></section> |
|
27 <section><title>Example</title><codeblock xml:space="preserve">RSocketServ ss; |
|
28 |
|
29 // Connect to ESOCK |
|
30 ss.Connect(); |
|
31 |
|
32 // Perform operations on the socket server |
|
33 ... |
|
34 |
|
35 // Close the connection |
|
36 ss.Close(); |
|
37 </codeblock></section> |
|
38 <section><title>Further considerations</title><p> The <xref href="GUID-EF29C1D7-B1E5-370F-AE37-66231A6BE449.dita#GUID-EF29C1D7-B1E5-370F-AE37-66231A6BE449/GUID-C9E237C5-DCFB-3F66-87E5-63425156995C"><apiname>RSocketServ::Connect()</apiname></xref> function |
|
39 allows optional extra information to be sent to the Socket Server to change |
|
40 the performance of the connection. Two optional parameters are available: |
|
41 </p><ol> |
|
42 <li id="GUID-A41FB7DA-2EE4-460F-9698-70A50FB682EB"><p><b>Message Slots</b> - If the client application expects to keep |
|
43 a large number of requests open at the same time, then the client application |
|
44 can increase the message slots available to the connection.</p></li> |
|
45 <li id="GUID-FDEF0A30-F872-49DF-A7EC-3B975040E5DC"><p><b>Protocol Preference</b> - If the client application will use the |
|
46 connection to interact with only one protocol, then this protocol should |
|
47 be specified. The Socket Server uses the preferred protocol to improve the |
|
48 efficiency of the messages between the client application and the protocol</p></li> |
|
49 </ol></section> |
|
50 <section id="GUID-5AA882EF-269B-54A6-8CDB-B1E9F26BB7D5"><p>The <codeph>RSocketServ</codeph> connection |
|
51 allows a number of <xref href="GUID-D0D27AEA-FDDB-5F6F-94F6-ADDF5910DC47.dita">sub-connections</xref> that |
|
52 offer more functionality. The sub-connections available are: </p> <ul> |
|
53 <li id="GUID-8C317F12-D19A-5B61-A88E-E1BC10BBFE78"><p> <xref href="GUID-EF29C1D7-B1E5-370F-AE37-66231A6BE449.dita"><apiname>RConnection</apiname></xref> </p> </li> |
|
54 <li id="GUID-DA08493B-DB72-57F0-9CB9-CF4BE80A94E9"><p> <xref href="GUID-EF29C1D7-B1E5-370F-AE37-66231A6BE449.dita"><apiname>RSubConnection</apiname></xref> </p> </li> |
|
55 <li id="GUID-28A3F706-7A81-5F72-8E66-0D236EDE6A40"><p> <xref href="GUID-EF29C1D7-B1E5-370F-AE37-66231A6BE449.dita"><apiname>RSocket</apiname></xref> </p> </li> |
|
56 <li id="GUID-F0D169F8-7C22-5AC1-BF22-EAC4D07B9E21"><p> <xref href="GUID-EF29C1D7-B1E5-370F-AE37-66231A6BE449.dita"><apiname>RHostResolver</apiname></xref> </p> </li> |
|
57 <li id="GUID-3A4ADFEA-4FCD-54DD-8367-0A42D21A67A6"><p> <xref href="GUID-EF29C1D7-B1E5-370F-AE37-66231A6BE449.dita"><apiname>RNetDatabase</apiname></xref> </p> </li> |
|
58 </ul> <p>The purpose of each of these sub-connections is described in the |
|
59 . </p> <p><b>Procedure</b> </p> <p>The |
|
60 procedure to attach any of these sub-connections is: </p> <ol id="GUID-E146CDDE-DE2C-579C-901F-073C63C61F6D"> |
|
61 <li id="GUID-E67862A6-17E4-5F5D-8A45-F7F8BEA01E04"><p>Create or use an existing <codeph>RSocketServ</codeph> session. </p> </li> |
|
62 <li id="GUID-C2AD2B55-F247-5D27-B368-4467E05D5800"><p>Call the <codeph>Open()</codeph> function |
|
63 on the object for the sub-connection class. Pass into the <codeph>Open()</codeph> function |
|
64 a reference to the <codeph>RSocketServ</codeph> session. </p> </li> |
|
65 <li id="GUID-18FF884F-8930-5851-9ECD-6B9BA55A48B2"><p>Perform sub-connection |
|
66 operations </p> </li> |
|
67 <li id="GUID-0A21C702-5125-55D1-8313-E1E7D1949C54"><p>Call <codeph>Close</codeph> to |
|
68 end the sub-session </p> </li> |
|
69 </ol> <p id="GUID-F5AEE180-B9A9-542E-84C9-2C505FD75AA4-GENID-1-8-1-8-1-1-10-1-5-1-4-1-3-1-3-5-7"><b>Example 1: Socket (RSocket)</b> </p> <codeblock id="GUID-FB43255E-E22E-5818-B00D-9351DA7B1BFF" xml:space="preserve">RSocketServ ss; |
|
70 RSocket sock; |
|
71 |
|
72 // Connect to the Sockets Server |
|
73 ss.Connect(); |
|
74 |
|
75 // open a socket |
|
76 sock.Open(ss); |
|
77 |
|
78 // Perform operations on the socket |
|
79 ... |
|
80 |
|
81 // Close the socket connection |
|
82 sock.Close(); |
|
83 </codeblock> <p id="GUID-F5AEE180-B9A9-542E-84C9-2C505FD75AA4-GENID-1-8-1-8-1-1-10-1-5-1-4-1-3-1-3-5-9"><b>Example 2: Connection Management |
|
84 (RConnection)</b> </p> <codeblock id="GUID-BA4575AA-B370-594C-AAE0-8D2D970CA4E0" xml:space="preserve">RSocketServ ss; |
|
85 RConnection conn; |
|
86 |
|
87 // Connect to the Sockets Server |
|
88 ss.Connect(); |
|
89 |
|
90 // Open the Connection Management sub-connection |
|
91 conn.Open(ss); |
|
92 |
|
93 // Perform operations on the connection |
|
94 ... |
|
95 |
|
96 // Close the sub-connection and connection |
|
97 ss.Close(); |
|
98 </codeblock> <p>This example shows that you do not need to close sub-connections |
|
99 explicitly. If you close the RSocketServ connection, the Comms Framework closes |
|
100 all attached sub-connections. </p> </section> |
|
101 </conbody><related-links> |
|
102 <link href="GUID-E34D0F11-4B34-575C-BE78-8EAD13E9CD64.dita"><linktext>How to |
|
103 Start and Close a Management Plane session: Tutorial</linktext> |
|
104 </link> |
|
105 <link href="GUID-12C9C36B-8AD4-544E-A6A3-54A799EF0280.dita"><linktext>Socket Server |
|
106 Reference</linktext></link> |
|
107 </related-links></concept> |