Symbian
Symbian Developer Library

SYMBIAN OS V9.4

Feedback

[Index] [Previous] [Next]


Getting started with Symbian OS client-server

The client-server framework is an important part of Symbian OS. There is necessarily a level of complexity in implementing a server for your application(s), but we provide client interface code and server code that you can copy and paste into your own implementations.

We classify Symbian OS servers into three basic types:

[Top]


Transient servers

Transient servers are normally the most difficult to code because they introduce the most complex startup and shutdown situations. However, they are in common use, and by providing you with working code, we ensure that:

  1. you handle startup and shutdown situations correctly.

  2. client code and server code follow a common pattern.

The transient server supplied here runs in a thread in its own process. This gives the server independence from its clients. This is important because if the client were to create the server as a separate thread within its own process, then the server would exit, i.e. terminate, if its owning process terminated. This would be true even if clients in other processes were still connected to it.

Equally as important:

There are four main parts to the code we supply:

If you have a devkit, then you can find a copy of the source in the directories under:

The source code is also included within this documentation; you can find it in the following locations: bld.inf, src, test, EABI, and BWINS.


The client interface

The client interface effectively forms the gateway to the server. All requests to the server, including requests to connect to it are routed through this; it is built from the following files:

t-client.mmp

This file defines the essential elements of the project that builds the client interface DLL. You import this into your IDE and build it.

The main points to note are:

See also : Platform security, Build tools guide, How to build DLLs and MMP file syntax

t-client.h

This is the header file that defines the classes used by the client interface.

The client interface defines just one class: RMySession derived from RSessionBase. An RSessionBase (derived) object represents the client side session and forms a channel of communication between the client and the server. Requests to the server, and information received from the server are channelled through this object. Note that the client side session object is mirrored by a server side session object, an instance of a class derived from CSession2, which in this server is called CMySession.

The main points to note are:

client.cpp

This file contains the implementation for the client interface.

The main point of interest here is how the Connect() function is implemented. It attempts to create a session with the server first, and if this fails because the server does not exist or is in the process of closing down, then the function attempts to start it. Simultaneous launching of two such server processes will be detected, with the second attempt failing with KErrAlreadyExists.


The server

t-server.mmp

This file defines the essential elements of the project that builds the server. You import this into your IDE and build it.

The main points to note are:

See also : Platform security, Build tools guide, How to build EXEs and MMP file syntax

server.h

This is the header file that defines the classes, function prototypes, enums etc used by the server.

The main points to note are:

server.cpp

This file contains the server implementation.

There are number of points of interest here:

See also Build tools guide, How to build EXEs and MMP file syntax