THRIFT-1558 Named Pipe and Anonymous Pipe transport for Windows
Patch: Peace
add pipe crossplatform example to contrib

git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1351477 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/contrib/transport-sample/Makefile b/contrib/transport-sample/Makefile
new file mode 100644
index 0000000..89e03b8
--- /dev/null
+++ b/contrib/transport-sample/Makefile
@@ -0,0 +1,25 @@
+THRIFT_DIR =../..
+INCS_DIRS  =-I${THRIFT_DIR}/lib/cpp/src -I.
+THRIFT_LIB =${THRIFT_DIR}/lib/cpp/.libs/libthrift.a
+BOOST_LIB  =
+CPP_DEFS   =
+CPP_OPTS   =-Wall -O2
+
+GEN_SRC    = gen-cpp/SampleService.cpp  \
+             gen-cpp/Sample_types.cpp   \
+             gen-cpp/SampleCallback.cpp \
+             gen-cpp/Sample_constants.cpp
+GEN_INC    = -Igen-cpp
+
+default: server client
+.PHONY: server client
+
+server:
+	g++ ${CPP_OPTS} ${CPP_DEFS} -o server/server ${GEN_INC} ${INCS_DIRS} server/server.cpp ${GEN_SRC} ${THRIFT_LIB} ${BOOST_LIB}
+
+client:
+	g++ ${CPP_OPTS} ${CPP_DEFS} -o client/client ${GEN_INC} ${INCS_DIRS} client/client.cpp ${GEN_SRC} ${THRIFT_LIB} ${BOOST_LIB}
+
+clean:
+	$(RM) -r client/client server/server
+
diff --git a/contrib/transport-sample/README.txt b/contrib/transport-sample/README.txt
new file mode 100644
index 0000000..a1dfc0a
--- /dev/null
+++ b/contrib/transport-sample/README.txt
@@ -0,0 +1,61 @@
+Thrift transport sample project
+-------------------------------
+
+This cross-platform project has been built with Windows Visual Studio 10 and 
+OSX 10.7.1's g++.  The client and server support socket and pipe transports 
+through command-line switches.
+
+Windows supports both named & anonymous pipes; *NIX gets only named 
+'pipes' at this time.
+
+Windows-only at this time:
+The client & server are double-ended. Both sides run a server and client to 
+enable full duplex bidirectional event signaling. They are simple command 
+line apps. The server runs until it's aborted (Ctl-C). The client connects to
+the server, informs the server of its listening pipe/port, runs some more RPCs 
+and exits. The server also makes RPC calls to the client to demonstrate 
+bidirectional operation.
+
+Prequisites:
+Boost -- tested with Boost 1.47, other versions may work.
+libthrift library -- build the library under "thrift/lib/cpp/"
+thrift IDL compiler -- download from http://thrift.apache.org/download/ 
+   or build from "thrift/compiler/cpp".  The IDL compiler version should
+   match the thrift source distribution's version. For instance, thrift-0.9.0
+   has a different directory structure than thrift-0.8.0 and the generated
+   files are not compatible.
+
+Note: Bulding the thrift IDL compiler and library are beyond the scope
+of this article. Please refer to the Thrift documentation in the respective
+directories and online.
+
+
+Microsoft Windows with Visual Studio 10
+----------------------------------------
+Copy the IDL compiler 'thrift.exe' to this project folder or to a location in the path.
+Run thriftme.bat to generate the interface source from the thrift files.
+
+Open transport-sample.sln and...
+Adapt the Boost paths for the client and server projects. Right-click on each project, select
+Properties, then:
+Configuration Properties -> C/C++ -> General -> Additional Include Directories
+Configuration Properties -> Linker -> General -> Additional Include Directories
+
+The stock path assumes that Boost is located at the same level as the thrift repo root.
+
+Run the following in separate command prompts from the Release or Debug 
+build folder:
+ server.exe -np test
+ client.exe -np test
+
+
+*NIX flavors
+------------
+Build the thrift cpp library.
+Build the IDL compiler and copy it to this project folder.
+Run thriftme.sh to generate the interface source from the thrift files.
+Run 'make'
+
+Run the following in separate shells:
+ server/server -np /tmp/test
+ client/client -np /tmp/test
diff --git a/contrib/transport-sample/Sample.thrift b/contrib/transport-sample/Sample.thrift
new file mode 100644
index 0000000..3040e25
--- /dev/null
+++ b/contrib/transport-sample/Sample.thrift
@@ -0,0 +1,39 @@
+/*
+ transport-sample thrift IDL file .
+ Execute thriftme.bat under Windows to generate the cpp stubs from this IDL.
+ */
+
+// See thrift/tutorial/tutorial.thrift and shared.thrift for more extensive examples.
+
+
+namespace cpp Sample
+namespace java Sample
+namespace perl Sample
+
+//This struct is not used in the sample. Shown here for illustrative purposes only.
+//
+struct SampleStruct
+{
+  1: i32 key
+  2: string value
+}
+
+
+//A service contains the RPC(s).
+//
+service SampleService
+{
+  string HelloThere(1:string HelloString),
+  void ServerDoSomething(),
+
+  //Client calls this to tell server which port to connect back on.
+  void ClientSideListenPort(1:i16 Port),
+  //Named pipe version
+  void ClientSidePipeName(1:string name),
+}
+
+//Sample RPC on the 'client' side that the master server can call.
+service SampleCallback
+{
+  void pingclient(),
+}
diff --git a/contrib/transport-sample/ThriftCommon.cpp b/contrib/transport-sample/ThriftCommon.cpp
new file mode 100644
index 0000000..60ebf7a
--- /dev/null
+++ b/contrib/transport-sample/ThriftCommon.cpp
@@ -0,0 +1,37 @@
+// ThriftCommon.cpp : Common functions for sample Thrift client and server
+//
+
+#include "ThriftCommon.h"
+
+namespace thriftcommon
+{
+	//----------------------------------------------------------------------------
+	//Launch child process and pass R/W anonymous pipe handles on cmd line.
+	//This is a simple example and does not include elevation or other 
+	//advanced features.
+	//
+	bool LaunchAnonPipeChild(std::string app, boost::shared_ptr<TServerTransport> transport)
+	{
+#ifdef _WIN32
+		PROCESS_INFORMATION pi;
+		STARTUPINFOA si;
+		GetStartupInfoA(&si);  //set startupinfo for the spawned process
+		char handles[MAX_PATH];  //Stores pipe handles converted to text
+
+		sprintf(handles, "%s %d %d", app.c_str(),
+			(int)boost::shared_dynamic_cast<TPipeServer>(transport)->getClientRdPipeHandle(),
+			(int)boost::shared_dynamic_cast<TPipeServer>(transport)->getClientWrtPipeHandle());
+
+		//spawn the child process
+		if (!CreateProcessA(NULL, handles, NULL,NULL,TRUE,0,NULL,NULL,&si,&pi))
+		{
+			GlobalOutput.perror("TPipeServer CreateProcess failed, GLE=", GetLastError());
+			return false;
+		}
+
+		CloseHandle(pi.hThread);
+		CloseHandle(pi.hProcess);
+#endif
+		return true;
+	}
+}
diff --git a/contrib/transport-sample/ThriftCommon.h b/contrib/transport-sample/ThriftCommon.h
new file mode 100644
index 0000000..d24d1a7
--- /dev/null
+++ b/contrib/transport-sample/ThriftCommon.h
@@ -0,0 +1,207 @@
+// ThriftCommon.h : Common includes, namespaces and templates 
+// for sample Thrift client and server
+//
+// Add the following paths to the Project's properties:
+//
+// Configuration Properties -> C/C++ -> General-> Additional Include Directories --
+// ../;../../../lib/cpp/src;../../../../boost;../../../../boost/boost/tr1;
+//
+// Configuration Properties -> Linker -> General -> Additional Library Directories --
+// ../../../lib/cpp/$(Configuration);../../../../Boost/lib
+//
+// Configuration Properties -> Linker -> Input -> Additional Dependencies --
+// libthrift.lib
+//
+// ... adjust relative paths as necessary.
+//
+
+#ifdef _WIN32 //thrift is crashing when using boost threads on Mac OSX
+#  define USE_BOOST_THREAD 1
+#  include <boost/thread.hpp>
+#else
+#  include <sys/socket.h>
+#  include <netinet/in.h>
+#endif
+
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// Required Includes
+//'server' side #includes
+#include <thrift/concurrency/ThreadManager.h>
+#include <thrift/concurrency/PlatformThreadFactory.h>
+#include <thrift/server/TThreadPoolServer.h>
+#include <thrift/server/TSimpleServer.h>
+//'client' side #includes
+#include <thrift/transport/TPipeServer.h>
+#include <thrift/transport/TPipe.h>
+#include <thrift/transport/TBufferTransports.h>
+#include <thrift/transport/TSocket.h>
+#include <thrift/transport/TTransport.h>
+
+#include <thrift/protocol/TBinaryProtocol.h>
+
+
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// Required Namespaces
+//'server' side namespaces
+using namespace apache::thrift::server;
+using namespace apache::thrift::concurrency;
+//common namespaces
+using namespace apache::thrift;
+using namespace apache::thrift::protocol;
+using namespace apache::thrift::transport;
+//using namespace boost; //using ns boost can introduce type conflicts
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+namespace thriftcommon
+{
+	//----------------------------------------------------------------------------
+	//
+	//Start the thrift 'server' (both server & client side run one for bidir event signaling)
+	// *** This function template will block ***
+	//
+	template <class MyHandler, class MyProcessor>
+	void RunThriftServer (boost::shared_ptr<MyHandler> hndlr, 
+		                  int NumThreads, 
+						  boost::shared_ptr<TServerTransport> transport,
+						  boost::shared_ptr<TServer> &server)
+	{
+#ifdef _WIN32
+		if (!hndlr.get())
+			throw std::exception("RunThriftServer() invalid handler");
+		if (!transport.get())
+			throw std::exception("RunThriftServer() invalid transport");
+#else
+		if ( !hndlr.get() || !transport.get() )
+			throw std::exception();
+#endif
+
+		boost::shared_ptr<MyHandler> handler(hndlr);
+		boost::shared_ptr<TProcessor> processor(new MyProcessor(handler));
+		boost::shared_ptr<TTransportFactory> tfactory(new TBufferedTransportFactory());
+		boost::shared_ptr<TProtocolFactory> pfactory(new TBinaryProtocolFactory());
+
+		if(NumThreads <= 1)
+		{	//Single-threaded server
+			server.reset(new TSimpleServer(processor, transport, tfactory, pfactory));
+		}
+		else
+		{	//Multi-threaded server
+			boost::shared_ptr<ThreadManager> threadManager = ThreadManager::newSimpleThreadManager(NumThreads);
+			boost::shared_ptr<PlatformThreadFactory> threadFactory = boost::shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory());
+			threadManager->threadFactory(threadFactory);
+			threadManager->start();
+			server.reset(new TThreadPoolServer(processor, transport, tfactory, pfactory, threadManager));
+		}
+
+		printf("Starting the 'server'...\n");
+		server->serve();
+		printf("done.\n");
+	}
+
+	// Thrift server wrapper function that accepts a pipe name.
+	// A handler must be passed in to this version.
+	template <class MyHandler, class MyProcessor>
+	void RunThriftServer (boost::shared_ptr<MyHandler> hndlr, int NumThreads, std::string pipename, boost::shared_ptr<TServer> &svr)
+	{
+#ifndef _WIN32  //Mac, *nix
+		unlink(pipename.c_str());
+#endif
+		boost::shared_ptr<TServerTransport> transport(new TPipeServer(pipename, 1024, NumThreads)); //Named pipe
+		RunThriftServer<MyHandler, MyProcessor>(hndlr, NumThreads, transport, svr);
+	}
+
+	// Thrift server wrapper function that accepts a pipe name.
+	// This version instantiates its own handler.
+	template <class MyHandler, class MyProcessor>
+	void RunThriftServer (int NumThreads, std::string pipename)
+	{
+		boost::shared_ptr<MyHandler> handler(new MyHandler());
+		boost::shared_ptr<TServer> server;
+
+		RunThriftServer<MyHandler, MyProcessor>(handler, NumThreads, pipename, server);
+	}
+
+	// Thrift server wrapper function that accepts a socket port number.
+	// A handler must be passed in to this version.
+	template <class MyHandler, class MyProcessor>
+	void RunThriftServer (boost::shared_ptr<MyHandler> hndlr, int NumThreads, int Port)
+	{
+		boost::shared_ptr<TServerTransport> transport(new TServerSocket(Port));
+		boost::shared_ptr<TServer> server;
+		RunThriftServer<MyHandler, MyProcessor>(hndlr, NumThreads, transport, server);
+	}
+
+	// Thrift server wrapper function that accepts a socket port number.
+	// This version instantiates its own handler.
+	template <class MyHandler, class MyProcessor>
+	void RunThriftServer (int NumThreads, int Port)
+	{
+		boost::shared_ptr<MyHandler> handler(new MyHandler());
+
+		RunThriftServer<MyHandler, MyProcessor>(handler, NumThreads, Port);
+	}
+
+	//
+	template <class MyHandler, class MyProcessor>
+	void RunThriftServer (boost::shared_ptr<MyHandler> hndlr, int NumThreads, boost::shared_ptr<TServerTransport> transport)
+	{
+		boost::shared_ptr<TServer> server;
+		RunThriftServer<MyHandler, MyProcessor>(hndlr, NumThreads, transport, server);
+	}
+
+	//----------------------------------------------------------------------------
+	//Connect to thrift 'server' - Socket version
+	//(both server & client side run one for bidir event signaling)
+	//
+	template <class MyClient, class MyTransport>
+	void ConnectToServer (boost::shared_ptr<MyClient> &client, boost::shared_ptr<MyTransport> &transport, int Port)
+	{
+		//Client side connection using sockets transport.
+		boost::shared_ptr<TTransport> socket(new TSocket("localhost", Port));
+		transport.reset(new TBufferedTransport(socket));
+		boost::shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport));
+
+		client.reset(new MyClient(protocol));
+	}
+
+	//Connect to thrift 'server' - Named Pipe version
+	template <class MyClient, class MyTransport>
+	void ConnectToServer (boost::shared_ptr<MyClient> &client, boost::shared_ptr<MyTransport> &transport, std::string pipename)
+	{
+		//Client side connection using Named Pipe transport.
+		boost::shared_ptr<TTransport> pipe(new TPipe(pipename));
+		transport.reset(new TBufferedTransport(pipe));
+		boost::shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport));
+
+		client.reset(new MyClient(protocol));
+	}
+
+	//Connect to thrift 'server' - Anonymous Pipe version
+	//Currently only supported under Windows
+#ifdef _WIN32
+	template <class MyClient, class MyTransport>
+	void ConnectToServer (boost::shared_ptr<MyClient> &client, boost::shared_ptr<MyTransport> &transport, HANDLE RdPipe, HANDLE WrtPipe)
+	{
+		//Client side connection using sockets transport.
+#ifdef _WIN32
+		boost::shared_ptr<TTransport> pipe(new TPipe((int)RdPipe, (int)WrtPipe));
+		transport.reset(new TBufferedTransport(pipe));
+#else
+		boost::shared_ptr<TTransport> socket(new TSocket("localhost"));
+		transport.reset(new TBufferedTransport(socket));
+#endif
+		boost::shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport));
+
+		client.reset(new MyClient(protocol));
+	}
+#endif
+
+	//----------------------------------------------------------------------------
+	//Launch child process and pass R/W anonymous pipe handles on cmd line.
+	//Currently only supported under Windows
+#ifdef _WIN32
+	bool LaunchAnonPipeChild(std::string app, boost::shared_ptr<TServerTransport> transport);
+#endif
+}
diff --git a/contrib/transport-sample/client/ReadMe.txt b/contrib/transport-sample/client/ReadMe.txt
new file mode 100644
index 0000000..6c49a96
--- /dev/null
+++ b/contrib/transport-sample/client/ReadMe.txt
@@ -0,0 +1,40 @@
+========================================================================
+    CONSOLE APPLICATION : client Project Overview
+========================================================================
+
+AppWizard has created this client application for you.
+
+This file contains a summary of what you will find in each of the files that
+make up your client application.
+
+
+client.vcxproj
+    This is the main project file for VC++ projects generated using an Application Wizard.
+    It contains information about the version of Visual C++ that generated the file, and
+    information about the platforms, configurations, and project features selected with the
+    Application Wizard.
+
+client.vcxproj.filters
+    This is the filters file for VC++ projects generated using an Application Wizard. 
+    It contains information about the association between the files in your project 
+    and the filters. This association is used in the IDE to show grouping of files with
+    similar extensions under a specific node (for e.g. ".cpp" files are associated with the
+    "Source Files" filter).
+
+client.cpp
+    This is the main application source file.
+
+/////////////////////////////////////////////////////////////////////////////
+Other standard files:
+
+StdAfx.h, StdAfx.cpp
+    These files are used to build a precompiled header (PCH) file
+    named client.pch and a precompiled types file named StdAfx.obj.
+
+/////////////////////////////////////////////////////////////////////////////
+Other notes:
+
+AppWizard uses "TODO:" comments to indicate parts of the source code you
+should add to or customize.
+
+/////////////////////////////////////////////////////////////////////////////
diff --git a/contrib/transport-sample/client/client.cpp b/contrib/transport-sample/client/client.cpp
new file mode 100644
index 0000000..45fbef1
--- /dev/null
+++ b/contrib/transport-sample/client/client.cpp
@@ -0,0 +1,195 @@
+// client->cpp : Defines the entry point for the console application.
+//
+// sample client command line app using Thrift IPC.
+// Quick n Dirty example, may not have very robust error handling
+// for the sake of simplicity.
+
+#ifdef _WIN32
+#  include "stdafx.h"
+#else
+#  include "config.h"
+#endif
+
+
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+//Include this before the generated includes
+#include "ThriftCommon.h"
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+//Tailor these to your generated files
+#include "../gen-cpp/SampleService.h"
+#include "../gen-cpp/SampleCallback.h"
+
+using namespace Sample; //declared in .thrift file
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+void ClientListenerThreadProc();
+bool bSocket = false;
+bool bAnonPipe = false;
+int srvPort;
+std::string pipename;
+std::string pipename_client;
+#ifdef _WIN32
+ HANDLE hConsole;
+#endif
+
+//Customized version of printf that changes the text color
+//This depends on hConsole global being initialized
+void hlprintf(const char* _Format, ...)
+{
+#ifdef _WIN32
+	SetConsoleTextAttribute(hConsole, 0xE);
+#endif
+	va_list ap;
+	int r;
+	va_start (ap, _Format);
+	r = vprintf (_Format, ap);
+	va_end (ap);
+#ifdef _WIN32
+	SetConsoleTextAttribute(hConsole, 7);
+#endif
+}
+
+//-----------------------------------------------------------------------------
+// Client-side RPC implementations: Called by the server to the client for 
+// bidirectional eventing.
+//
+class SampleCallbackHandler : virtual public SampleCallbackIf {
+ public:
+  SampleCallbackHandler() {
+    // initialization goes here
+  }
+
+  void pingclient()
+  {
+    hlprintf("<<<Ping received from server (server-to-client event).\n");
+  }
+
+};
+//-----------------------------------------------------------------------------
+
+
+#ifdef _WIN32
+int _tmain(int argc, _TCHAR* argv[])
+#else
+int main(int argc, char **argv)
+#endif
+{
+	//Process cmd line args to determine named vs anon pipes.
+	bool usage = false;
+#ifdef _WIN32
+	HANDLE ReadPipe, WritePipe;
+	hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
+#endif
+
+	//Process command line params
+	if(argc > 1)
+	{
+		if(_tcscmp(argv[1], TEXT("-sp")) == 0)
+		{	//Socket Port specified
+			srvPort = _tstoi(argv[2]);
+			bSocket = true;
+		}
+		else if(_tcscmp(argv[1], TEXT("-np")) == 0)
+		{	//Named Pipe specified
+#ifdef _WIN32
+                        std::wstring wpipe(argv[2]);
+                        pipename.resize(wpipe.length());
+                        std::copy(wpipe.begin(), wpipe.end(), pipename.begin());
+#else
+                        pipename = argv[2];
+#endif
+			pipename_client = pipename + "_client";
+		}
+		else if(argc == 3)
+		{	//Anonymous Pipe specified
+#ifdef _WIN32
+			ReadPipe  = (HANDLE)_tstoi(argv[1]);
+			WritePipe = (HANDLE)_tstoi(argv[2]);
+			bAnonPipe = true;
+#else
+                        printf("Anonymous pipes not (yet) supported under *NIX\n");
+#endif
+		}
+		else
+			usage = true;
+	}
+	else
+		usage = true;
+
+	if(usage)
+	{
+		hlprintf("Thrift sample client usage:\n\n");
+		hlprintf("Socket Port to connect to: -sp <port#>\n");
+		hlprintf("Named Pipe to connect to:  -np <pipename> (e.g. affpipe)\n");
+		hlprintf("Anonymous Pipe (must be launched by anon pipe creator):\n");
+		hlprintf("                           <Read Handle> <Write Handle>\n");
+		return 0;
+	}
+
+	//Client side connection to server.
+	boost::shared_ptr<SampleServiceClient> client; //Client class from Thrift-generated code.
+	boost::shared_ptr<TTransport> transport;
+
+	if(bSocket)
+	{	//Socket transport
+#ifdef _WIN32
+		TWinsockSingleton::create();
+#endif
+		hlprintf("Using socket transport port %d\n", srvPort);
+		thriftcommon::ConnectToServer<SampleServiceClient, TTransport>(client, transport, srvPort);
+	}
+	else if(!bAnonPipe)
+	{
+		hlprintf("Using Named Pipe %s\n", pipename.c_str());
+		thriftcommon::ConnectToServer<SampleServiceClient, TTransport>(client, transport, pipename);
+	}
+	else
+	{
+#ifdef _WIN32
+		hlprintf("Using Anonymous Pipe transport\n");
+		thriftcommon::ConnectToServer<SampleServiceClient, TTransport>(client, transport, ReadPipe, WritePipe);
+#endif
+	}
+
+#ifdef _WIN32
+	//Start a thread to receive inbound connection from server for 2-way event signaling.
+	boost::thread ClientListenerThread(ClientListenerThreadProc);
+#endif
+
+	try {
+		transport->open();
+
+		//Notify server what to connect back on.
+		if(bSocket)
+			client->ClientSideListenPort(srvPort + 1); //Socket
+		else if(!bAnonPipe)
+			client->ClientSidePipeName(pipename_client); //Named Pipe
+
+		//Run some more RPCs
+		std::string hellostr = "Hello how are you?";
+		std::string returnstr;
+		client->HelloThere(returnstr, hellostr);
+		hlprintf("\n>>>Sent: %s\n", hellostr.c_str());
+		hlprintf("<<<Received: %s\n", returnstr.c_str());
+
+		hlprintf("\n>>>Calling ServerDoSomething() which delays for 5 seconds.\n");
+		client->ServerDoSomething();
+		hlprintf(">>>ServerDoSomething() done.\n\n");
+
+		transport->close();
+	} catch (TException &tx) {
+		hlprintf("ERROR: %s\n", tx.what());
+	}
+
+	return 0;
+}
+
+
+//Thread Routine
+void ClientListenerThreadProc()
+{
+	if(bSocket)
+		thriftcommon::RunThriftServer<SampleCallbackHandler, SampleCallbackProcessor>(1, srvPort + 1);
+	else if(!bAnonPipe)
+		thriftcommon::RunThriftServer<SampleCallbackHandler, SampleCallbackProcessor>(1, pipename_client);
+}
diff --git a/contrib/transport-sample/client/client.vcxproj b/contrib/transport-sample/client/client.vcxproj
new file mode 100644
index 0000000..779c339
--- /dev/null
+++ b/contrib/transport-sample/client/client.vcxproj
@@ -0,0 +1,105 @@
+?<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup Label="ProjectConfigurations">
+    <ProjectConfiguration Include="Debug|Win32">
+      <Configuration>Debug</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|Win32">
+      <Configuration>Release</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+  </ItemGroup>
+  <PropertyGroup Label="Globals">
+    <ProjectGuid>{85FBFB54-530B-498F-9F38-44BA204FAE6A}</ProjectGuid>
+    <Keyword>Win32Proj</Keyword>
+    <RootNamespace>client</RootNamespace>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+  <ImportGroup Label="ExtensionSettings">
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <PropertyGroup Label="UserMacros" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <LinkIncremental>true</LinkIncremental>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <LinkIncremental>false</LinkIncremental>
+  </PropertyGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <ClCompile>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Disabled</Optimization>
+      <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <AdditionalIncludeDirectories>../;../../../lib/cpp/src;../../../../boost;../../../../boost/boost/tr1;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+    </ClCompile>
+    <Link>
+      <SubSystem>Console</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <AdditionalLibraryDirectories>../../../lib/cpp/$(Configuration);../../../../Boost/lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+      <AdditionalDependencies>libthrift.lib;ws2_32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <Optimization>MaxSpeed</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <AdditionalIncludeDirectories>../;../../../lib/cpp/src;../../../../boost;../../../../boost/boost/tr1;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+    </ClCompile>
+    <Link>
+      <SubSystem>Console</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+      <AdditionalLibraryDirectories>../../../lib/cpp/$(Configuration);../../../../Boost/lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+      <AdditionalDependencies>libthrift.lib;ws2_32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemGroup>
+    <None Include="ReadMe.txt" />
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="..\gen-cpp\SampleCallback.h" />
+    <ClInclude Include="..\gen-cpp\SampleService.h" />
+    <ClInclude Include="..\gen-cpp\Sample_constants.h" />
+    <ClInclude Include="..\gen-cpp\Sample_types.h" />
+    <ClInclude Include="stdafx.h" />
+    <ClInclude Include="targetver.h" />
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="..\ThriftCommon.cpp" />
+    <ClCompile Include="..\gen-cpp\SampleCallback.cpp" />
+    <ClCompile Include="..\gen-cpp\SampleService.cpp" />
+    <ClCompile Include="..\gen-cpp\Sample_constants.cpp" />
+    <ClCompile Include="..\gen-cpp\Sample_types.cpp" />
+    <ClCompile Include="client.cpp" />
+    <ClCompile Include="stdafx.cpp" />
+  </ItemGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+  <ImportGroup Label="ExtensionTargets">
+  </ImportGroup>
+</Project>
\ No newline at end of file
diff --git a/contrib/transport-sample/client/client.vcxproj.filters b/contrib/transport-sample/client/client.vcxproj.filters
new file mode 100644
index 0000000..3ec7bde
--- /dev/null
+++ b/contrib/transport-sample/client/client.vcxproj.filters
@@ -0,0 +1,66 @@
+?<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup>
+    <Filter Include="Source Files">
+      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+    </Filter>
+    <Filter Include="Header Files">
+      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
+    </Filter>
+    <Filter Include="Resource Files">
+      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
+      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
+    </Filter>
+    <Filter Include="Source Files\gen-cpp">
+      <UniqueIdentifier>{1265b3dc-91de-416f-aba6-7b750de4221e}</UniqueIdentifier>
+    </Filter>
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="ReadMe.txt" />
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="stdafx.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="targetver.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="..\gen-cpp\Sample_types.h">
+      <Filter>Source Files\gen-cpp</Filter>
+    </ClInclude>
+    <ClInclude Include="..\gen-cpp\SampleService.h">
+      <Filter>Source Files\gen-cpp</Filter>
+    </ClInclude>
+    <ClInclude Include="..\gen-cpp\Sample_constants.h">
+      <Filter>Source Files\gen-cpp</Filter>
+    </ClInclude>
+    <ClInclude Include="..\gen-cpp\SampleCallback.h">
+      <Filter>Source Files\gen-cpp</Filter>
+    </ClInclude>
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="stdafx.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="client.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\gen-cpp\SampleService.cpp">
+      <Filter>Source Files\gen-cpp</Filter>
+    </ClCompile>
+    <ClCompile Include="..\gen-cpp\Sample_constants.cpp">
+      <Filter>Source Files\gen-cpp</Filter>
+    </ClCompile>
+    <ClCompile Include="..\gen-cpp\Sample_types.cpp">
+      <Filter>Source Files\gen-cpp</Filter>
+    </ClCompile>
+    <ClCompile Include="..\gen-cpp\SampleCallback.cpp">
+      <Filter>Source Files\gen-cpp</Filter>
+    </ClCompile>
+    <ClCompile Include="..\ThriftCommon.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+  </ItemGroup>
+</Project>
diff --git a/contrib/transport-sample/client/stdafx.cpp b/contrib/transport-sample/client/stdafx.cpp
new file mode 100644
index 0000000..4bd151e
--- /dev/null
+++ b/contrib/transport-sample/client/stdafx.cpp
@@ -0,0 +1,8 @@
+// stdafx.cpp : source file that includes just the standard includes
+// client.pch will be the pre-compiled header
+// stdafx.obj will contain the pre-compiled type information
+
+#include "stdafx.h"
+
+// TODO: reference any additional headers you need in STDAFX.H
+// and not in this file
diff --git a/contrib/transport-sample/client/stdafx.h b/contrib/transport-sample/client/stdafx.h
new file mode 100644
index 0000000..b005a83
--- /dev/null
+++ b/contrib/transport-sample/client/stdafx.h
@@ -0,0 +1,15 @@
+// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently, but
+// are changed infrequently
+//
+
+#pragma once
+
+#include "targetver.h"
+
+#include <stdio.h>
+#include <tchar.h>
+
+
+
+// TODO: reference additional headers your program requires here
diff --git a/contrib/transport-sample/client/targetver.h b/contrib/transport-sample/client/targetver.h
new file mode 100644
index 0000000..87c0086
--- /dev/null
+++ b/contrib/transport-sample/client/targetver.h
@@ -0,0 +1,8 @@
+#pragma once
+
+// Including SDKDDKVer.h defines the highest available Windows platform.
+
+// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
+// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
+
+#include <SDKDDKVer.h>
diff --git a/contrib/transport-sample/config.h b/contrib/transport-sample/config.h
new file mode 100644
index 0000000..a20d785
--- /dev/null
+++ b/contrib/transport-sample/config.h
@@ -0,0 +1,24 @@
+//Missing definitions for *NIX systems. This sample project
+//was initially created on Windows.
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define TEXT(str) str
+
+inline int Sleep(int ms)
+{
+	return sleep(ms/1000); //sleep() param is in seconds
+}
+
+inline int _tcscmp(const char* str1, const char* str2)
+{
+	return strcmp(str1, str2);
+}
+
+inline int _tstoi(const char* str)
+{
+	return atoi(str);
+}
+
diff --git a/contrib/transport-sample/server/ReadMe.txt b/contrib/transport-sample/server/ReadMe.txt
new file mode 100644
index 0000000..53c0ee5
--- /dev/null
+++ b/contrib/transport-sample/server/ReadMe.txt
@@ -0,0 +1,40 @@
+========================================================================
+    CONSOLE APPLICATION : server Project Overview
+========================================================================
+
+AppWizard has created this server application for you.
+
+This file contains a summary of what you will find in each of the files that
+make up your server application.
+
+
+server.vcxproj
+    This is the main project file for VC++ projects generated using an Application Wizard.
+    It contains information about the version of Visual C++ that generated the file, and
+    information about the platforms, configurations, and project features selected with the
+    Application Wizard.
+
+server.vcxproj.filters
+    This is the filters file for VC++ projects generated using an Application Wizard. 
+    It contains information about the association between the files in your project 
+    and the filters. This association is used in the IDE to show grouping of files with
+    similar extensions under a specific node (for e.g. ".cpp" files are associated with the
+    "Source Files" filter).
+
+server.cpp
+    This is the main application source file.
+
+/////////////////////////////////////////////////////////////////////////////
+Other standard files:
+
+StdAfx.h, StdAfx.cpp
+    These files are used to build a precompiled header (PCH) file
+    named server.pch and a precompiled types file named StdAfx.obj.
+
+/////////////////////////////////////////////////////////////////////////////
+Other notes:
+
+AppWizard uses "TODO:" comments to indicate parts of the source code you
+should add to or customize.
+
+/////////////////////////////////////////////////////////////////////////////
diff --git a/contrib/transport-sample/server/server.cpp b/contrib/transport-sample/server/server.cpp
new file mode 100644
index 0000000..dba8368
--- /dev/null
+++ b/contrib/transport-sample/server/server.cpp
@@ -0,0 +1,168 @@
+// server.cpp : Defines the entry point for the console application.
+//
+// sample server command line app using Thrift IPC.
+//
+// This is a simple demonstration of full duplex RPC. That is, each
+// side runs both a client and server to enable bidirectional event 
+// signaling.
+//
+
+#ifdef _WIN32
+#  include "stdafx.h"
+#else
+#  include "config.h"
+#endif
+
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+//Include this before the generated includes
+#include "ThriftCommon.h"
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+//Tailor these to your generated files
+#include "../gen-cpp/SampleService.h"
+#include "../gen-cpp/SampleCallback.h"
+
+using namespace Sample; //declared in .thrift file
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+int16_t ClientPort_;
+std::string ClientPipeName_;
+void S2CThreadProc();
+
+//-----------------------------------------------------------------------------
+// RPC implementations
+//
+class SampleServiceHandler : virtual public SampleServiceIf {
+ public:
+  SampleServiceHandler() {
+    // Your initialization goes here
+  }
+
+  void HelloThere(std::string& _return, const std::string& HelloString) {
+    // Your implementation goes here
+    printf("<<<HelloThere() received string: %s\n", HelloString.c_str());
+	_return = "Good thank you.";
+  }
+
+  void ServerDoSomething() {
+    // Your implementation goes here
+    printf("ServerDoSomething(): Simulating work for 5 seconds\n");
+    Sleep(5000);
+    printf("ServerDoSomething(): Done\n");
+  }
+
+  void ClientSideListenPort(const int16_t ClientListenPort)
+  {
+	ClientPort_ = ClientListenPort;
+	ClientPipeName_ = "";
+#ifdef _WIN32
+	printf(">>>Connecting to client on port %d\n", ClientPort_);
+	boost::thread Connect2ClientThread(S2CThreadProc);
+#endif
+  }
+
+  void ClientSidePipeName(const std::string& ClientPipeName)
+  {
+	ClientPipeName_ = ClientPipeName;
+	ClientPort_ = 0;
+#ifdef _WIN32
+	printf(">>>Connecting to client pipe %s\n", ClientPipeName_.c_str());
+	boost::thread Connect2ClientThread(S2CThreadProc);
+#endif
+  }
+};
+//-----------------------------------------------------------------------------
+
+#ifdef _WIN32
+int _tmain(int argc, _TCHAR* argv[])
+#else
+int main(int argc, char **argv)
+#endif
+{
+	int port;
+	std::string pipename; //e.g. "affpipe"
+
+	bool usage = false;
+
+	//Process command line params
+	if(argc > 1)
+	{
+		if(_tcscmp(argv[1], TEXT("-sp")) == 0)
+		{	//Socket Port specified
+			port = _tstoi(argv[2]);
+#ifdef _WIN32
+			TWinsockSingleton::create();
+#endif
+			// Start the thrift server which is a blocking call.
+			thriftcommon::RunThriftServer<SampleServiceHandler, SampleServiceProcessor>(10, port);
+		}
+		else if(_tcscmp(argv[1], TEXT("-np")) == 0)
+		{	//Named Pipe specified
+#ifdef _WIN32
+			std::wstring wpipe(argv[2]);
+			pipename.resize(wpipe.length());
+			std::copy(wpipe.begin(), wpipe.end(), pipename.begin());
+#else
+			pipename = argv[2];
+#endif
+			printf("Using Named Pipe %s\n", pipename.c_str());
+
+			//Thrift over Named Pipe.
+			thriftcommon::RunThriftServer<SampleServiceHandler, SampleServiceProcessor>(10, pipename);
+		}
+		else if(_tcscmp(argv[1], TEXT("-ap")) == 0)
+		{	//Anonymous Pipe specified
+			//This is more involved because the child needs to be launched 
+			//after the transport is created but before the blocking server 
+			//call.
+#ifdef _WIN32
+			boost::shared_ptr<TServerTransport> transport(new TPipeServer()); //Anonymous pipe
+			thriftcommon::LaunchAnonPipeChild(".\\client.exe", transport);
+			boost::shared_ptr<SampleServiceHandler> handler(new SampleServiceHandler());
+			thriftcommon::RunThriftServer<SampleServiceHandler, SampleServiceProcessor>(handler, 10, transport);
+#else
+			printf("Anonymous pipes not (yet) supported under *NIX\n");
+#endif
+		}
+		else
+			usage = true;
+	}
+	else
+		usage = true;
+
+	if(usage)
+	{
+		printf("Thrift sample server usage:\n\n");
+		printf("Socket Port :   -sp <port#>\n");
+		printf("Named Pipe :    -np <pipename> (e.g. affpipe)\n");
+		printf("Anonymous Pipe: -ap\n");
+	}
+	return 0;
+}
+
+
+//Thread Routine that connects to the 'client'.
+void S2CThreadProc()
+{
+	//Master server's connection to client-side's server.
+	boost::shared_ptr<SampleCallbackClient> clientsrv; //Client class from Thrift-generated code.
+	boost::shared_ptr<TTransport> transport;
+	if(ClientPort_ != 0)
+		thriftcommon::ConnectToServer<SampleCallbackClient, TTransport>(clientsrv, transport, ClientPort_);
+	if(!ClientPipeName_.empty())
+		thriftcommon::ConnectToServer<SampleCallbackClient, TTransport>(clientsrv, transport, ClientPipeName_);
+
+	try {
+		transport->open();
+
+		clientsrv->pingclient();
+		Sleep(1500);
+		clientsrv->pingclient();
+		Sleep(1500);
+		clientsrv->pingclient();
+
+		transport->close();
+	} catch (TException &tx) {
+		printf("ERROR: %s\n", tx.what());
+	}
+}
+
diff --git a/contrib/transport-sample/server/server.vcxproj b/contrib/transport-sample/server/server.vcxproj
new file mode 100644
index 0000000..8e39b26
--- /dev/null
+++ b/contrib/transport-sample/server/server.vcxproj
@@ -0,0 +1,106 @@
+?<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup Label="ProjectConfigurations">
+    <ProjectConfiguration Include="Debug|Win32">
+      <Configuration>Debug</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|Win32">
+      <Configuration>Release</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+  </ItemGroup>
+  <PropertyGroup Label="Globals">
+    <ProjectGuid>{72FCAF29-506D-4164-9FA6-F54C5C28E79D}</ProjectGuid>
+    <Keyword>Win32Proj</Keyword>
+    <RootNamespace>server</RootNamespace>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+  <ImportGroup Label="ExtensionSettings">
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <PropertyGroup Label="UserMacros" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <LinkIncremental>true</LinkIncremental>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <LinkIncremental>false</LinkIncremental>
+  </PropertyGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <ClCompile>
+      <PrecompiledHeader>NotUsing</PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Disabled</Optimization>
+      <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <AdditionalIncludeDirectories>../;../../../lib/cpp/src;../../../../Boost/;../../../../Boost/boost/tr1;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+    </ClCompile>
+    <Link>
+      <SubSystem>Console</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <AdditionalLibraryDirectories>../../../lib/cpp/$(Configuration);../../../../Boost/lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+      <AdditionalDependencies>libthrift.lib;ws2_32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <PrecompiledHeader>NotUsing</PrecompiledHeader>
+      <Optimization>MaxSpeed</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <AdditionalIncludeDirectories>../;../../../lib/cpp/src;../../../../Boost/;../../../../Boost/boost/tr1;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+    </ClCompile>
+    <Link>
+      <SubSystem>Console</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+      <AdditionalLibraryDirectories>../../../lib/cpp/$(Configuration);../../../../Boost/lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+      <AdditionalDependencies>libthrift.lib;ws2_32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemGroup>
+    <None Include="ReadMe.txt" />
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="..\gen-cpp\SampleCallback.h" />
+    <ClInclude Include="..\gen-cpp\SampleService.h" />
+    <ClInclude Include="..\gen-cpp\Sample_constants.h" />
+    <ClInclude Include="..\gen-cpp\Sample_types.h" />
+    <ClInclude Include="stdafx.h" />
+    <ClInclude Include="targetver.h" />
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="..\ThriftCommon.cpp" />
+    <ClCompile Include="..\gen-cpp\SampleCallback.cpp" />
+    <ClCompile Include="..\gen-cpp\SampleService.cpp" />
+    <ClCompile Include="..\gen-cpp\Sample_constants.cpp" />
+    <ClCompile Include="..\gen-cpp\Sample_types.cpp" />
+    <ClCompile Include="server.cpp" />
+    <ClCompile Include="stdafx.cpp">
+      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
+      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
+    </ClCompile>
+  </ItemGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+  <ImportGroup Label="ExtensionTargets">
+  </ImportGroup>
+</Project>
\ No newline at end of file
diff --git a/contrib/transport-sample/server/server.vcxproj.filters b/contrib/transport-sample/server/server.vcxproj.filters
new file mode 100644
index 0000000..8bb6dfb
--- /dev/null
+++ b/contrib/transport-sample/server/server.vcxproj.filters
@@ -0,0 +1,66 @@
+?<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup>
+    <Filter Include="Source Files">
+      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+    </Filter>
+    <Filter Include="Header Files">
+      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
+    </Filter>
+    <Filter Include="Resource Files">
+      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
+      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
+    </Filter>
+    <Filter Include="Source Files\gen-cpp">
+      <UniqueIdentifier>{dab66db8-bc45-4518-aad2-7a75696226e3}</UniqueIdentifier>
+    </Filter>
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="ReadMe.txt" />
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="stdafx.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="targetver.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="..\gen-cpp\Sample_types.h">
+      <Filter>Source Files\gen-cpp</Filter>
+    </ClInclude>
+    <ClInclude Include="..\gen-cpp\SampleService.h">
+      <Filter>Source Files\gen-cpp</Filter>
+    </ClInclude>
+    <ClInclude Include="..\gen-cpp\Sample_constants.h">
+      <Filter>Source Files\gen-cpp</Filter>
+    </ClInclude>
+    <ClInclude Include="..\gen-cpp\SampleCallback.h">
+      <Filter>Source Files\gen-cpp</Filter>
+    </ClInclude>
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="stdafx.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="server.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\gen-cpp\Sample_types.cpp">
+      <Filter>Source Files\gen-cpp</Filter>
+    </ClCompile>
+    <ClCompile Include="..\gen-cpp\SampleService.cpp">
+      <Filter>Source Files\gen-cpp</Filter>
+    </ClCompile>
+    <ClCompile Include="..\gen-cpp\Sample_constants.cpp">
+      <Filter>Source Files\gen-cpp</Filter>
+    </ClCompile>
+    <ClCompile Include="..\gen-cpp\SampleCallback.cpp">
+      <Filter>Source Files\gen-cpp</Filter>
+    </ClCompile>
+    <ClCompile Include="..\ThriftCommon.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+  </ItemGroup>
+</Project>
diff --git a/contrib/transport-sample/server/stdafx.cpp b/contrib/transport-sample/server/stdafx.cpp
new file mode 100644
index 0000000..c25ff61
--- /dev/null
+++ b/contrib/transport-sample/server/stdafx.cpp
@@ -0,0 +1,8 @@
+// stdafx.cpp : source file that includes just the standard includes
+// server.pch will be the pre-compiled header
+// stdafx.obj will contain the pre-compiled type information
+
+#include "stdafx.h"
+
+// TODO: reference any additional headers you need in STDAFX.H
+// and not in this file
diff --git a/contrib/transport-sample/server/stdafx.h b/contrib/transport-sample/server/stdafx.h
new file mode 100644
index 0000000..b005a83
--- /dev/null
+++ b/contrib/transport-sample/server/stdafx.h
@@ -0,0 +1,15 @@
+// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently, but
+// are changed infrequently
+//
+
+#pragma once
+
+#include "targetver.h"
+
+#include <stdio.h>
+#include <tchar.h>
+
+
+
+// TODO: reference additional headers your program requires here
diff --git a/contrib/transport-sample/server/targetver.h b/contrib/transport-sample/server/targetver.h
new file mode 100644
index 0000000..87c0086
--- /dev/null
+++ b/contrib/transport-sample/server/targetver.h
@@ -0,0 +1,8 @@
+#pragma once
+
+// Including SDKDDKVer.h defines the highest available Windows platform.
+
+// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
+// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
+
+#include <SDKDDKVer.h>
diff --git a/contrib/transport-sample/thrift-sample.sln b/contrib/transport-sample/thrift-sample.sln
new file mode 100644
index 0000000..a9fa1ef
--- /dev/null
+++ b/contrib/transport-sample/thrift-sample.sln
@@ -0,0 +1,26 @@
+?
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "server", "server\server.vcxproj", "{72FCAF29-506D-4164-9FA6-F54C5C28E79D}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "client", "client\client.vcxproj", "{85FBFB54-530B-498F-9F38-44BA204FAE6A}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Win32 = Debug|Win32
+		Release|Win32 = Release|Win32
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{72FCAF29-506D-4164-9FA6-F54C5C28E79D}.Debug|Win32.ActiveCfg = Debug|Win32
+		{72FCAF29-506D-4164-9FA6-F54C5C28E79D}.Debug|Win32.Build.0 = Debug|Win32
+		{72FCAF29-506D-4164-9FA6-F54C5C28E79D}.Release|Win32.ActiveCfg = Release|Win32
+		{72FCAF29-506D-4164-9FA6-F54C5C28E79D}.Release|Win32.Build.0 = Release|Win32
+		{85FBFB54-530B-498F-9F38-44BA204FAE6A}.Debug|Win32.ActiveCfg = Debug|Win32
+		{85FBFB54-530B-498F-9F38-44BA204FAE6A}.Debug|Win32.Build.0 = Debug|Win32
+		{85FBFB54-530B-498F-9F38-44BA204FAE6A}.Release|Win32.ActiveCfg = Release|Win32
+		{85FBFB54-530B-498F-9F38-44BA204FAE6A}.Release|Win32.Build.0 = Release|Win32
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+EndGlobal
diff --git a/contrib/transport-sample/thriftme.bat b/contrib/transport-sample/thriftme.bat
new file mode 100644
index 0000000..4b1ef78
--- /dev/null
+++ b/contrib/transport-sample/thriftme.bat
@@ -0,0 +1 @@
+thrift.exe --gen cpp Sample.thrift
diff --git a/contrib/transport-sample/thriftme.sh b/contrib/transport-sample/thriftme.sh
new file mode 100644
index 0000000..3b18f90
--- /dev/null
+++ b/contrib/transport-sample/thriftme.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+THRIFT_COMPILER=./thrift
+OUTPUT_FOLDER=$PWD
+
+if [ ! -e "${THRIFT_COMPILER}" ]
+then
+   THRIFT_COMPILER=thrift
+   command -v  ${THRIFT_COMPILER} >/dev/null 2>&1
+   if [ $? -eq 1 ]; then
+      echo
+      echo "thrift compiler not found."
+      echo
+      exit
+   fi
+fi
+
+${THRIFT_COMPILER} --gen cpp Sample.thrift
+
+echo
+echo "Files have been generated in gen-cpp."
+
+exit
+
diff --git a/contrib/transport-sample/transport-sample.sln b/contrib/transport-sample/transport-sample.sln
new file mode 100644
index 0000000..a9fa1ef
--- /dev/null
+++ b/contrib/transport-sample/transport-sample.sln
@@ -0,0 +1,26 @@
+?
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "server", "server\server.vcxproj", "{72FCAF29-506D-4164-9FA6-F54C5C28E79D}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "client", "client\client.vcxproj", "{85FBFB54-530B-498F-9F38-44BA204FAE6A}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Win32 = Debug|Win32
+		Release|Win32 = Release|Win32
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{72FCAF29-506D-4164-9FA6-F54C5C28E79D}.Debug|Win32.ActiveCfg = Debug|Win32
+		{72FCAF29-506D-4164-9FA6-F54C5C28E79D}.Debug|Win32.Build.0 = Debug|Win32
+		{72FCAF29-506D-4164-9FA6-F54C5C28E79D}.Release|Win32.ActiveCfg = Release|Win32
+		{72FCAF29-506D-4164-9FA6-F54C5C28E79D}.Release|Win32.Build.0 = Release|Win32
+		{85FBFB54-530B-498F-9F38-44BA204FAE6A}.Debug|Win32.ActiveCfg = Debug|Win32
+		{85FBFB54-530B-498F-9F38-44BA204FAE6A}.Debug|Win32.Build.0 = Debug|Win32
+		{85FBFB54-530B-498F-9F38-44BA204FAE6A}.Release|Win32.ActiveCfg = Release|Win32
+		{85FBFB54-530B-498F-9F38-44BA204FAE6A}.Release|Win32.Build.0 = Release|Win32
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+EndGlobal