AdvancedClientServerExample: Using Client/Server APIs

This example application demonstrates the use of client/server APIs using a logical device driver (LDD) and a physical device driver (PDD).

Introduction

This example implements asynchronous as well as synchronous client requests to the server. This example also demonstrates a client and server running in separate processes and a client and server running in the same process.

This example demonstrates the following:

  • a server running its own process: This is referred to in this document as the process server. The example also implements a DLL that provides an API to allow clients to request services from the process server. This client DLL is referred to as the process client.

  • a server and client running in a single process: These are referred to as the thread server and thread client.

  • a shut down server: This terminates the process or thread server if it has no clients connected to it for 50 seconds.

Download

Process Client and Server

Click the following links to download the example:

ProcessClient.zip

ProcessServer.zip

Click the following links for additional files:

ProcessServerInc.zip

Common.zip

Driver.zip

Click the following links to view the example:

browse ProcessClient

browse ProcessServer

Click the following links to view additional files:

browse ProcessServerInc

browse Common

browse Driver

Thread Client and Server

Click the following links to download the example:

ThreadClient.zip

ThreadServer.zip

Click the following links to download additional files:

ThreadServerInc.zip

Driver.zip

CommonInc.zip

Common.zip

Click the following links to view the example:

browse ThreadClient

browse ThreadServer

Click the following links to view additional files

browse ThreadServerInc

browse Driver

browse CommonInc

browse Common

Directories

common

This directory contains code that is common to the process and thread servers. It implements the shut down server which checks the number of connected clients to the thread or process server. If this number is zero, then after a time delay, the thread/process server is terminated. The server is not terminated in the following cases:

  • if the client tries to connect within the duration of the timer, then the shut down operation is cancelled and the server handles the client's request to connect.

  • if the client tries to connect after the timer has expired but before the server shut down process has begun, then the process or thread server is stopped and restarted to handle the client's request to connect.

driver

Device drivers are DLLs that allow code to communicate with hardware. For more information about device drivers, see the Device Driver Guide.

ProcessClient

This directory implements a client DLL that starts the process server and creates a session with it. The client DLL provides an API to allow clients to request the server to load and unload the device driver.

ProcessServer

This directory implements the process server class CProcessServer, which is derived from CServer2. It handles client requests to interact with the device drivers. It can have multiple clients connected at the same time. The device driver, server and client all have the MultimediaDD capability. Note that this is for demonstration purposes rather than because the code uses any Multimedia APIs. The session class CProcessServerSession implements a simple message queue to hold asynchronous requests.

ThreadClient

This directory implements a client DLL that starts the thread server and creates a session within it. The client DLL provides an API to allow clients to request the server to load and unload the device driver.

ThreadServer

This directory implements the thread server class CThreadServer, which is derived from CServer2. An instance of the thread server runs in the same process as the client. The thread server handles client requests to interact with the device drivers. It can have multiple clients connected at the same time. The session class CThreadServerSession implements a simple message queue to hold asynchronous requests.

test

This example directory contains a comprehensive test suite to test the process client and server and the thread client and server.

Build

Build the development and test code using the abld build command from AdvancedClientServerExample\group.

The AdvancedClientServerExample builds the following binaries in the standard location (\epoc32\release\winscw\<build_variant> for CodeWarrior):

  • driver1_ldd.ldd.

  • driver1_pdd.pdd.

  • processclient.dll,threadclient.dll and threadserver.dll. ,\

  • processserver.exe, Te_ProcessClientServerTestSuite.exe and Te_ThreadClientServerTestSuite.exe.

After launching the Te_ProcessClientServerTestSuite.exe or Te_ThreadClientServerTestSuite.exe executable, depending on the emulator you are using, you may have to navigate away from the application launcher/shell screen to view the console.

Running tests

To run the tests, perform the following steps:

  • From the command prompt, change directory to epoc32\release\winscw\udeb.

  • Run the following command:

    epoc

  • On the emulator, go to eshell.

  • Run the following commands:

    testexecute c:\testdata\scripts\te_processclientservertestsuite.script

    testexecute c:\testdata\scripts\te_threadclientservertestsuite.script

    Note: Test results are stored in the epoc32\winscw\c\logs\testexecute directory:

  • Process server tests: Refer to the te_processclientservertestsuite.htm file.

  • Thread server tests: Refer to the te_threadclientservertestsuite.htm file.

Related concepts
Inter Process Communication
Related information
Device Driver Guide