Skip to content

Instantly share code, notes, and snippets.

Last active December 23, 2019 14:39
Show Gist options
  • Save daiplusplus/7c46d7433d1543b32ad022cfae99f041 to your computer and use it in GitHub Desktop.
Save daiplusplus/7c46d7433d1543b32ad022cfae99f041 to your computer and use it in GitHub Desktop.

As an opening remark, remember it's 2019 and WCF is obsolete and I"m personally glad to see it gone, and I strongly recommend against using WCF for any new projects and I advise people to transition away from WCF as soon as possible.

Does WCF use sockets internally for the communication in all cases. In other words is WCF a wrapper around sockets and is built upon them?

Short-answer: Yes, with an "if".
Long-answer: No, with a "but".

WCF is a .NET platform originally designed for SOAP - and SOAP has many different transports (most notably HTTP), but also supports other protocols (that all follow SOAP's general design, unfortunately), such as net.tcp which is essentially a binary form of SOAP.

On Win32, networking is accomplished using Winsock - which is Microsoft's implementation of the BSD Sockets API - so if you're using WCF to communicate between machines then eventually your messages will pass-through Winsock - but this doesn't necessarily have to be the case - for example, you can avoid Winsock by using a different networking API that operates through a lower-level or some kind of exotic networking system that BSD Sockets / Winsock doesn't support (I think Banyan Vines didn't use Winsock, but I might be wrong).

For example - you can still use WCF - but you could reconfigure its message handling and redirect all IO to a system that doesn't use sockets - for example, if you use WCF entirely within a self-contained process - and this is how you can unit-test WCF applications (but it would be silly to do this in production code, of course). You could also use WCF to read and write messages to a local filesystem.

Another way to use WCF without using Winsock is to use WCF to exchange SOAP messages over SMTP (SOAP supports multiple transports, like HTTP and SMTP) and you can use SMTP without going through the TCP stack by using techniques like "pickup directories" (many email servers, including Microsoft Exchange, can be configured to monitor a filesystem folder

Copy link

sisirkp commented Dec 23, 2019

Thanks. It really helped. However, could you explain more on the examples of WCF not using WinSock. That part I am having difficulty understanding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment