A Simple Server
For the server we create a new elf console application Hello Server. To use the Tcp Server Channel class, we have to reference the System. Runtime. Remoting assembly. It’s also required that we reference the Remote Hello assembly that we created earlier. In the Main () method a System. Runtime . Remoting . Channel . Tcp. Tcp Server Channel is created with the port number 8086. This channel is registered with the System. Runtime. Remoting. Channels. Channel Services class to make it available for remote objects. The remote object type is registered using System Runtime Remoting Remoting Configuration Register We Known Service Type.
Here we specify the type of the class in the remote object, the URI that is used by the client, and a mode. The mode Well Known Object. Single Call means that a new instance is created for every method call; we do not hold state in the remote object.
After registration of the remote object, we keep the server running until a key is pressed: