Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What to use? WCF or Sockets? in a C# program

Tags:

c#

wcf

sockets

I am in the need of creating a C# program that will run on couple of our local Windows client machines. These 'client' programs will have to take commands from a 'admin' program run on another machine. The commands could be to reboot the client computers, return some local information about IP address etc back to the 'admin' program.

But how to accomplish this? I know a little about WCF but is that the right way to go? If I go with WCF I will then have to make the client programs run a service method, like every second, to check for new commands. With sockets I establish a 'direct' connection and the client just waits for a command to receive - isn't that correct understood?

Which way would be the right way for me to go?

We are talking about ~10 clients and I want a maximum delay (send command - receive info back) of 1 second.

Any hints would also be appreciated.

Best regards

like image 619
user1281991 Avatar asked Jan 13 '23 08:01

user1281991


1 Answers

Duplex WCF server. Basically, the clients all connect into the server (so only 1 server), and the server uses its duplex channel to call back to the clients whenever it needs to. No polling, scales well, etc. The most headache you'll need to deal with is to set a long timeout in case that you don't send anything for a while so that the channels time out.

WCF will end up being much simpler in the end.

A couple of links:

http://msdn.microsoft.com/en-us/library/ms731064.aspx

and

http://www.codeproject.com/Articles/491844/A-Beginners-Guide-to-Duplex-WCF

I hope those help.

like image 170
Kevin Anderson Avatar answered Jan 21 '23 22:01

Kevin Anderson