Remoting Sample
Sample Overview
This sample demonstrates various aspects of the System.Runtime.Remoting
namespace.
There are three elements to this sample:
- Client: This is the client application that creates objects and
passes them to the server application.
- Server: This application waits for input from the client and responds.
- Shared: This library contains a shared object definition used by both
client and server applications.
The server application supports the following user-specified options:
- Communicate over HTTP, TCP, or both channels at the same time. This
must match what the client will use when opening channels to the server.
- Use either SingleCall or Singleton object modes. SingleCall destroys
the remoted object after each invocation. Singleton keeps the object
alive and reuses it for each invocation.
- ByRef or ByVal calling convention. This must match what the client
will use to pass the remote object to the server.
The client application supports the following user-specified options:
- Communicate over HTTP, TCP, or both channels at the same time. This
must match the option used by the server or the channel will not open. If the option to use both channels is selected, then the client will use
threads to invoke the server. If either HTTP or TCP are specified then
the client will not use separate threads but will invoke the server from the
main thread.
- Pass ByRef or ByVal objects to the server. This option must match
the option used by the server or a exception will occur.
- Invoke the server sequentially or asynchronously. This is
client-side only behavior. It demonstrates two different ways of
implementing the server invocation.
The shared library implements objects that are either MarshalByRef (for being
passed by reference) or serializable (for being passed by value). The client
and server applications switch between these object types depending on user input.
Sample Source and Build Output Locations
The sample source is found in rotor\samples\howto\remoting in the client,
server, and shared subdirectories.
The source files are:
The build output location is %TARGETCOMPLUS%\samples\howto\remoting.
The output files are executable assemblies named remotingclient.exe and
remotingserver.exe, and a library assembly named remotingshared.dll.
Building the Sample
All samples are built from the buildall script.
You can also build all the
samples by switching to the root of the sample directory, sscli\samples, and typing
build -c.
You can build this specific sample by switching to the sample directory and typing
build -c.
Running the Sample
These steps require that the Shared Source CLI (SSCLI) be already built and
functional.
- Run env.bat or source the env.csh or env.sh script files depending on
your platform.
- Switch to the %TARGETCOMPLUS%\samples\howto\remoting directory.
- Type the following command:
clix remotingserver
- In another console window type:
clix remotingclient
The sample applications will prompt you for optional values. Make sure that
the client and server match input for object type (ByVal or ByRef) and
communication channels.
Copyright (c) 2002 Microsoft Corporation. All rights reserved.