2

Since I last had to do any comms/network programming, the field has exploded with acronyms. In fact, networking almost feels like it is now described by a whole new language.

The very name "Windows Communication Foundation" suggests it should be all things to all people... but I need to be sure I can program up some synchronous real-time* comms on a dedicated gigabit ethernet network. Can someone confirm that WCF is not a starter for this task... or if it is, which of the many confusing acronyms I should get familiar with?

* By real-time, I mean I need to reduce latencies down to an acceptably low level. For our application, which involves transmitting results of video & audio analyses continuously every few milliseconds, I need to ensure 99% or better of those analyses are presented at the UI within (ideally) 0.5 seconds so that the user has time to respond before the originating network node deletes data out of its buffer to make way for subsequent analyses.

3
  • 500ms latency requirement is nothing for WCF. Why would it take so long to issue a call? What exactly would take so long? No answer to these questions. Expect ~1ms of overhead for a WCF call that does nothing. Plus network latency. Plus maybe contention and overloading of the server.
    – usr
    Commented Jul 16, 2014 at 13:25
  • Precisely. Windows (at least in the past) has been notorious for being fine "most of the time", but occasionally some inexplicable contention would see these times blow out to unacceptable levels. What you have described makes WCF sound "fine most of the time" which doesn't sound good enough for my needs by comparison to rolling my own proprietary protocol on top of Winsock.
    – omatai
    Commented Jul 16, 2014 at 19:44
  • 1
    Please do convince me - by all means write an answer that says "no - I have an app written using WCF that serves 10 nodes on a dedicated network, each of which generates 100KB every 5ms. It runs like clockwork 24/7 with 0% packet loss on Windows 7". I'd be really interested in such an answer. But from what I've read, I'm just not expecting it.
    – omatai
    Commented Jul 16, 2014 at 21:26

2 Answers 2

2

For real time programming needs the Microsoft solution is SignalR. Other options would be to use web sockets which are new in HTML 5 or good old fashioned socket programming. It sounds like you need to do video/audio streaming, in which case there are other libraries dedicated to that which could be more helpful. WCF is XML/JSON over HTTP which does have an overhead cost if you are planning to send lots of continuous data, it would be better to use a technology that works at a lower level to reduce that overhead.

0

Basically, WCF is intended for asynchronous communications, and I won't be surprised to learn that at a certain level, everything it does it asynchronous.

This being said, you can do blocking operations with WCF, so yes, synchronous real-time communications can use WCF under the hood, given that WCF provides you some interesting aspects such as the fact that it can guarantee that messages will be delivered, and will be in the order they were sent.

The ability to use blocking operations includes even the WCF's web sockets, by the way.

Why would you block the thread until you receive a reply from a distant machine is a different subject. Think twice, since it you probably don't want to freeze your entire application definitively if the network goes down.

One of the uses I've found for blocking operations is to have a proxy class which communicates through WCF under the hood. In this case, when you access someObject.Products, you don't have to know that products are loaded through WCF. It's a powerful abstraction, but also a leaky one: if the distant machine goes down during the operation, you certainly have to know what happens when you call Products property.

3
  • Excellent - thanks. Your answer immediately made me want to search for what control there is over timeouts... which seems to be in seconds. A Microsoft page on "Configuring Timeout Values on a binding" failed to mention any time units that I could find. Do you happen to know the shortest timeout period that is supported?
    – omatai
    Commented Jul 16, 2014 at 7:58
  • @omatai: here, in the first example, the timeout is set in code using TimeSpan, which allows to specify the milliseconds. I don't know if you can specify milliseconds directly in the configuration file. Commented Jul 16, 2014 at 8:06
  • Note, that blocking a thread does not imply that an entire CPU core is now idle. Other requests can be served. There are some questionable statements about sync and async in this answer.
    – usr
    Commented Jul 16, 2014 at 13:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.