Socket Tunneling over WCF

by Mwwhited 13. November 2009 23:41

A few months back someone on Stack Overflow asked if it was possible to create a VPN client using WCF.  Unfortunately, while it is not possible to write a VPN client in 100% in WCF, it is possible to write a socket tunnel using WCF as the transport.  I wrote this tunneling proxy back in early 2008 as a proof of concept and it worked for most protocols.  (Pretty much anything that only used a single  socket connection that was may from the client to the server,  Kerbose and active FTP are known not to work at this time.  HTTP, SMTP, IMAP, and POP3 should all work)

Again this is a very rough tunneling proxy built using WCF with WS Dual HTTP Bindings and it requires a contact with SessionMode set to Required as well as a CallbackContact.  This code is known to work in the sample configuration but may require elevated rights on Windows Vista and Windows 7 so it may bind to a well known port number.

I do not support this code and only provide it as a sample of what is possible using WCF in a bi-directional operation.  Also being a proof of concept there is very little error handling.  Use at your own risk.  (Don’t forget network tunneling circumvent network security.)

Network Relay Sample Code



7/8/2013 6:31:14 PM #


Pingback from

VPN Tunneling using WCF | Q Sites

Comments are closed

Powered by BlogEngine.NET
Theme by Mads Kristensen