There are situation we need to communicate between application over network or in the same machine. There are several ways to implement the functionality. To communicate between application we have few options like .NEt Named Pipes, MSMQ, Enterprise services and Remoting.
Depends on the requirement we can select the communication option. In this blog i will discuss how to implement kind of chat application using .NET Remoting.
.NET Remoting Overview
The .NET remoting infrastructure is an abstract approach to inter-process communication. Objects that can be passed by value, or copied, are automatically passed between applications in different application domains or on different computers. Mark your custom classes as serializable to make this work.
Can read more on Remoting here.
Sample Code
The sample application which i am posting here has 3 major component to it
- Remoting Server
- Remoting Client
- Remoting Library
Remoting Server:
The Remoting Server module will open the connection using Tcp Channel on the specified port. The server also can send message to multiple client which are connected to receive the message.
Remoting Client:
The Remoting client will try to connect to the server and respond back with the message.
Remoting Library:
Remoting Library will have the Remotable Type object with the Message Response and the Message Transfer class type. Both the class types are serializable
Full source is here