Symbian3/SDK/Source/GUID-B75BD3DE-9C2E-5429-B55B-891462B92795.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Tue, 20 Jul 2010 12:00:49 +0100
changeset 13 48780e181b38
parent 7 51a74ef9ed63
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-B75BD3DE-9C2E-5429-B55B-891462B92795" xml:lang="en"><title>Connecting
to the service discovery database</title><shortdesc>Bluetooth services are registered to the service discovery database. </shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
<section id="GUID-C26FCD89-D659-4FE1-A604-EDBA577A47F7"><title>How to connect to the service discovery database</title> <p>The
first step in registering a service to the service discovery database is establishing
a connection to the database. </p> <p><b>Basic Procedure</b> </p> <p>To use
the service discovery database, a client must: </p> <ol id="GUID-094BC503-E351-513D-9EAE-5E75E93104AC">
<li id="GUID-4564B0E1-5CF7-53F1-B4E7-38CB386A4E28"><p>Create a session to
the database object, <xref href="GUID-0879B4D7-A6FA-382F-A124-0234BA89D33D.dita"><apiname>RSdp</apiname></xref>, and open a connection. </p> </li>
<li id="GUID-BBB6AB46-AE11-5579-9426-36CF9DF26D11"><p>Create a subsession
to the database object, <xref href="GUID-FC133F0F-C9E8-30CB-B2FE-8AC9F7F802AC.dita"><apiname>RSdpDatabase</apiname></xref>, and open it. A client
can have multiple subsessions open if required. (Sessions and subsessions
are part of Symbian platform's architecture for interprocess communication:
see <xref href="GUID-D0D27AEA-FDDB-5F6F-94F6-ADDF5910DC47.dita">Client/Server Overview</xref>). </p> </li>
<li id="GUID-6A5DE434-5D70-54EC-9584-3E1179F1AA8A"><p>Close subsessions and
sessions when they are no longer needed. </p> </li>
</ol> <p><b> Connecting
to the database </b> </p> <p>The following example shows how to connect to
the database: </p> <ul>
<li id="GUID-5B6792CF-D05F-5DA6-8CAC-2694705BEEA2"><p>Create and open a session
to the database </p> <codeblock id="GUID-BB8D1A05-E9D4-5252-90D6-58493545C53A" xml:space="preserve">RSdp sdp;
User::LeaveIfError(sdp.Connect());</codeblock> </li>
<li id="GUID-F962F78D-8875-517D-8DA6-5C42BAED5C50"><p>Create and open a subsession </p> <codeblock id="GUID-93C2E486-13BA-5B42-9947-A8E9D260C022" xml:space="preserve">RSdpDatabase sdpSubSession;
User::LeaveIfError(sdpSubSession.Open(sdp));</codeblock> </li>
<li id="GUID-2F7C3D26-8DA2-54F7-B2D2-061E5A1B4EEE"><p>Cleanup </p> <codeblock id="GUID-98CCF2D7-F1DC-5FD3-B4BC-0A762DF70EA1" xml:space="preserve">sdpSubSession.Close();
sdp.Close();</codeblock> </li>
</ul><p><note>  If all sessions to the SDP database are closed, then the database
is closed. Any application that offers a service should therefore keep a handle
to the database as long as it is offering the service.</note></p> </section>
<section id="GUID-5AEE030D-E281-43F9-BBBB-511C04D7A24B"><title>Where next?</title> <p>The complete set of Service Discovery
Database tutorials are shown below: </p> <ol id="GUID-0B5EA0D5-88F7-5E3B-A322-9DDB2632C245">
<li id="GUID-B5C6757E-67DE-50E9-9823-E37F6268689A"><p> <b>Connecting to the
service discovery database</b> - This document </p> </li>
<li id="GUID-9AA92312-5798-596B-A690-147DC7358BBC"><p> <xref href="GUID-E2A2FA2A-5D9A-56FE-B7E5-69CCBC656BB9.dita">Handling
SDP attributes</xref>  </p> </li>
<li id="GUID-5F8F22AB-476E-5E65-8EBE-750278B3CBD6"><p> <xref href="GUID-2373A158-C18A-51B5-BE9A-6B8F7FC63A35.dita">Registering
Services</xref>  </p> </li>
<li id="GUID-6926A768-C9EA-594F-B81F-6CF4F79CF66C"><p> <xref href="GUID-33210C48-3198-51BC-9970-8B29F711A8E2.dita">Setting
service record attributes</xref>  </p> </li>
<li id="GUID-68498D90-4BE3-5826-9DF1-06D790301F1C"><p> <xref href="GUID-ED342E6B-A4A3-576B-8934-7E7C049837F0.dita">SDP
Service records and attributes</xref>  </p> </li>
</ol> <p>Also refer to the <xref href="GUID-E5893C4A-024A-53A7-805F-68989382DC3F.dita">Bluetooth
Service Discovery Database overview</xref> and the <xref href="GUID-8451102A-8E68-5C86-9E40-D53183E32261.dita">Bluetooth
SDP Overview</xref> for additional background information. </p> </section>
</conbody></concept>