Initializing the server

Before you can start a server, you need to create a service definition. See "Creating a service definition" on page 33 for instructions.

To publish a server:

If you want your server to handle multiple requests concurrently, clone the initial TRequestReceiverStream instance and create a corresponding thread to process each request.

Calling TRequestReceiverStream::Open is optional. This member function publishes the service if the service is not already published. If you don't call Open, TRequestReceiverStream::Receive calls it for you.

NOTE If a service cannot be published, Open may propagate an exception--for example, if another service of the same name is already published on this host.

This code initiates the server by instantiating TNamedServiceDefinition and passing this to a TRequestReceiverStream instance:

      TRequestReceiverStream myReceiver ( myServiceDefinition ) ;
      myReceiver.Open () ;                                    // Optional
To create additional TRequestReceiverStream instances, clone the original one:

      TRequestReceiverStream mySecondReceiver ( myReceiver ) ;
      TRequestReceiverStream myThirdReceiver ( myReceiver ) ;
As an alternative, you can also construct additional TRequestReceiverStream objects in the same way you constructed the first one; you don't have to clone them.


[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker