Two-way communication server / client architecture?

I am trying to figure out which client / server technology (i.e. which part of the .NET Framework) is used for our new application. We will be writing an application in C # using .NET 3.5 SP1.

It will consist of a central service that will act as a β€œserver”, and several client applications are distributed on several machines. The client application is a trayapp application that will receive notifications from the server and also send some information back to the server. Thus, the message will be two-way, and it should be fast. The server needs to know which client should send notifications.

I thought I could use Sockets. I also came across the TcpListener and TcpClient classes. Another option is to do something with WCF, but I'm not sure how to make quick two-way communication with it.

+4
source share
3 answers

Not knowing how much data you plan to exchange, it is difficult to give an exact recommendation. I use both WCF and TCP sockets to exchange data between my user interface and my Windows service. These are the considerations I made.

I use WCF for what I call aperiodic data exchange. For example, when an event occurs in my Windows service, I pass the event to the user interface using WCF. In particular, for this event-based mechanism, I would highly recommend the Juval Lowy Publish-Subscribe Framework , which is available for free here . I also use WCF to push configuration changes from the user interface to the Windows service. WCF is the perfect solution for this kind of data exchange for me.

When a user informs my Windows service about some actions, a large amount of data is sent from the Windows service to the user interface. For this, I use TCP sockets. I know that WCF has streaming ability, and I strongly used it. I just did not have time to calm down before I had to make a decision, so I went with what I knew.

Although I wish I had used WCF all over the world for symmetry, i.e. for aperiodic and streaming data, this hybrid approach helped me well.

Hope this helps.

+3
source

WCF with NetTcp binding.

You must write a duplex service.

+4
source

I would avoid sockets if I were you because you know a lot about them. Just look at socket issues here in SO. It can be a nightmare if you do not know how to use them correctly.

WCF will take care of all the lower levels for you.

+1
source

All Articles