diff -Naur old/CMakeLists.txt cpp/CMakeLists.txt
--- old/CMakeLists.txt	1969-12-31 16:00:00.000000000 -0800
+++ cpp/CMakeLists.txt	2013-05-22 08:22:44.000000000 -0700
@@ -0,0 +1,91 @@
+#
+# JBoss, Home of Professional Open Source
+# Copyright 2010 Red Hat Inc. and/or its affiliates and other
+# contributors as indicated by the @author tags. All rights reserved.
+# See the copyright.txt in the distribution for a full listing of
+# individual contributors.
+#
+# This is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation; either version 2.1 of
+# the License, or (at your option) any later version.
+#
+# This software is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this software; if not, write to the Free
+# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+#
+
+cmake_minimum_required (VERSION 2.6)
+
+project (HotRod C CXX)
+
+#file(READ version.txt HR_VERSION_FILE)
+#string(REGEX MATCHALL "[0-9]+" HR_VERSION_LIST "${HR_VERSION_FILE}")
+
+#list(GET HR_VERSION_LIST 0 HR_VERSION_MAJOR)
+#list(GET HR_VERSION_LIST 1 HR_VERSION_MINOR)
+
+#set (HR_VERSION "${HR_VERSION_MAJOR}.${HR_VERSION_MINOR}")
+#message(STATUS "HR_VERSION: ${HR_VERSION}")
+
+enable_testing()
+include (CTest)
+
+include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/include" "${CMAKE_CURRENT_SOURCE_DIR}/src")
+
+if (CMAKE_COMPILER_IS_GNUCXX)
+   set (COMPILER_FLAGS "-fvisibility=hidden -fvisibility-inlines-hidden")
+   set (WARNING_FLAGS
+        "-Werror -pedantic -Wall -Wextra -Wno-shadow -Wpointer-arith -Wcast-qual -Wcast-align -Wno-long-long -Wvolatile-register-var -Winvalid-pch -Wno-system-headers -Woverloaded-virtual -Wshadow -Wl,--no-undefined")
+endif (CMAKE_COMPILER_IS_GNUCXX)
+
+if (MSVC)
+   set (COMPILER_FLAGS "")
+   set (WARNING_FLAGS "")
+endif (MSVC)
+
+if (NOT DEFINED COMPILER_FLAGS)
+    message(FATAL_ERROR "Compiler flags not set for this build type")
+endif (NOT DEFINED COMPILER_FLAGS)
+set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMPILER_FLAGS} ${WARNING_FLAGS}")
+
+if(WIN32 AND NOT CYGWIN)
+  # linking against Windows native libraries, including mingw
+  set (HOTROD_WINAPI TRUE)
+  set (platform_libs ws2_32 Rpcrt4)
+endif(WIN32 AND NOT CYGWIN)
+
+# Select driver
+if(HOTROD_WINAPI)
+  set (platform_sources src/hotrod/sys/windows/Socket.cpp)
+else(HOTROD_WINAPI)
+  set (platform_sources src/hotrod/sys/posix/Socket.cpp)
+endif(HOTROD_WINAPI)
+
+
+
+add_library (
+  hotrod SHARED
+  src/hotrod/api/RemoteCacheManager.cpp
+  src/hotrod/api/RemoteCacheBase.cpp
+  src/hotrod/api/exceptions.cpp
+  src/hotrod/impl/RemoteCacheManagerImpl.cpp
+  src/hotrod/impl/RemoteCacheImpl.cpp
+  src/hotrod/impl/operations/OperationsFactory.cpp
+  src/hotrod/impl/operations/GetOperation.cpp
+  src/hotrod/impl/operations/PutOperation.cpp
+  src/hotrod/impl/transport/Transport.cpp
+  ${platform_sources}
+  )
+target_link_libraries (hotrod ${platform_libs})
+
+add_executable (simple test/Simple.cpp)
+target_link_libraries (simple hotrod)
+add_test (simple simple)
+
diff -Naur old/include/infinispan/hotrod/exceptions.h cpp/include/infinispan/hotrod/exceptions.h
--- old/include/infinispan/hotrod/exceptions.h	1969-12-31 16:00:00.000000000 -0800
+++ cpp/include/infinispan/hotrod/exceptions.h	2013-05-17 09:10:56.000000000 -0700
@@ -0,0 +1,61 @@
+#ifndef ISPN_HOTROD_EXCEPTIONS_H
+#define ISPN_HOTROD_EXCEPTIONS_H
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010 Red Hat Inc. and/or its affiliates and other
+ * contributors as indicated by the @author tags. All rights reserved.
+ * See the copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+#include "infinispan/hotrod/ImportExport.h"
+#include <exception>
+#include <string>
+
+namespace infinispan {
+namespace hotrod {
+
+class HR_EXTERN Exception : public std::exception
+{
+  public:
+    explicit Exception(const std::string& message=std::string()) throw();
+    virtual ~Exception() throw();
+    virtual const char* what() const throw();
+
+  private:
+    const std::string message;
+};
+
+// Matching the names of the Java exceptions where possible, adding if
+// necessary.
+
+struct HR_EXTERN HotRodClientException : public Exception
+{
+    HotRodClientException(const std::string&);
+};
+
+struct HR_EXTERN TransportException : public Exception
+{
+    TransportException(const std::string&);
+};
+
+
+}} // namespace
+
+#endif  /* ISPN_HOTROD_EXCEPTIONS_H */
diff -Naur old/include/infinispan/hotrod/Handle.h cpp/include/infinispan/hotrod/Handle.h
--- old/include/infinispan/hotrod/Handle.h	1969-12-31 16:00:00.000000000 -0800
+++ cpp/include/infinispan/hotrod/Handle.h	2013-05-16 11:10:28.000000000 -0700
@@ -0,0 +1,43 @@
+#ifndef ISPN_HOTROD_HANDLE_H
+#define ISPN_HOTROD_HANDLE_H
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010 Red Hat Inc. and/or its affiliates and other
+ * contributors as indicated by the @author tags. All rights reserved.
+ * See the copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+#include "infinispan/hotrod/ImportExport.h"
+#include "infinispan/hotrod/types.h"
+
+namespace infinispan {
+namespace hotrod {
+
+template <class T> class Handle
+{
+  protected:
+    typedef HR_SHARED_PTR<T> Impl;
+    Handle(T* pimpl) : impl(pimpl){}
+    Impl impl;
+};
+
+}} // namespace
+
+#endif  /* ISPN_HOTROD_HANDLE_H */
diff -Naur old/include/infinispan/hotrod/ImportExport.h cpp/include/infinispan/hotrod/ImportExport.h
--- old/include/infinispan/hotrod/ImportExport.h	1969-12-31 16:00:00.000000000 -0800
+++ cpp/include/infinispan/hotrod/ImportExport.h	2013-05-22 17:01:16.000000000 -0700
@@ -0,0 +1,62 @@
+#ifndef HOTROD_IMPORT_EXPORT_H
+#define HOTROD_IMPORT_EXPORT_H 1
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010 Red Hat Inc. and/or its affiliates and other
+ * contributors as indicated by the @author tags. All rights reserved.
+ * See the copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+//
+// Compiler specific mechanisms for managing the import and export of
+// symbols between shared objects.
+//
+// HR_EXPORT         - Export declaration
+// HR_IMPORT         - Import declaration
+//
+
+#if !defined(HOTROD_DECLARE_STATIC)
+  #if defined(WIN32)
+    #define HR_EXPORT __declspec(dllexport)
+    #define HR_IMPORT __declspec(dllimport)
+  #else
+    #if __GNUC__ >= 4
+      #define HR_EXPORT __attribute__ ((visibility ("default")))
+      #define HR_IMPORT __attribute__ ((visibility ("default")))
+    #endif
+  #endif
+#endif
+
+#if !defined(HR_EXPORT)
+  // default values
+  #define HR_EXPORT
+  #define HR_IMPORT
+#endif
+
+
+// value of xxx_EXPORTS is set by CMake
+#ifdef hotrod_EXPORTS
+  #define HR_EXTERN HR_EXPORT
+#else
+  #define HR_EXTERN HR_IMPORT
+#endif
+
+
+#endif /* import_export.h */
diff -Naur old/include/infinispan/hotrod/Marshaller.h cpp/include/infinispan/hotrod/Marshaller.h
--- old/include/infinispan/hotrod/Marshaller.h	1969-12-31 16:00:00.000000000 -0800
+++ cpp/include/infinispan/hotrod/Marshaller.h	2013-05-16 11:24:43.000000000 -0700
@@ -0,0 +1,45 @@
+#ifndef ISPN_HOTROD_MARSHALLER_H
+#define ISPN_HOTROD_MARSHALLER_H
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010 Red Hat Inc. and/or its affiliates and other
+ * contributors as indicated by the @author tags. All rights reserved.
+ * See the copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+#include "infinispan/hotrod/ScopedBuffer.h"
+
+namespace infinispan {
+namespace hotrod {
+
+class ScopedBuffer;
+
+// Todo: application buffer memory management; async readers/writers.  SSL implications?
+
+template <class T> class Marshaller
+{
+  public:
+    virtual void marshall(const T&, ScopedBuffer&) = 0;
+    virtual T unmarshall(const ScopedBuffer&) = 0;
+};
+
+}} // namespace
+
+#endif  /* ISPN_HOTROD_MARSHALLER_H */
diff -Naur old/include/infinispan/hotrod/RemoteCacheBase.h cpp/include/infinispan/hotrod/RemoteCacheBase.h
--- old/include/infinispan/hotrod/RemoteCacheBase.h	1969-12-31 16:00:00.000000000 -0800
+++ cpp/include/infinispan/hotrod/RemoteCacheBase.h	2013-05-22 07:12:14.000000000 -0700
@@ -0,0 +1,59 @@
+#ifndef ISPN_HOTROD_REMOTECACHEBASE_H
+#define ISPN_HOTROD_REMOTECACHEBASE_H
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010 Red Hat Inc. and/or its affiliates and other
+ * contributors as indicated by the @author tags. All rights reserved.
+ * See the copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+#include "infinispan/hotrod/ImportExport.h"
+#include "infinispan/hotrod/Handle.h"
+
+namespace infinispan {
+namespace hotrod {
+
+class RemoteCacheImpl;
+typedef void (*MarshallHelperFn) (void*, const void *, void*);
+
+class HR_EXTERN RemoteCacheBase
+    : public infinispan::hotrod::Handle<RemoteCacheImpl>
+{
+ public:
+    void base_get(const void *key, void *rbuf);
+    void base_put(const void *key, const void *value);
+  protected:
+    RemoteCacheBase();
+    void setMarshallers(void* rc, MarshallHelperFn kf, MarshallHelperFn vf);
+
+  private:
+    void *remoteCachePtr;
+    MarshallHelperFn baseKeyMarshallFn;
+    MarshallHelperFn baseValueMarshallFn;
+    void baseKeyMarshall(const void* k, void *buf);
+    void baseValueMarshall(const void* v, void *buf);
+
+  friend class RemoteCacheManagerImpl;
+  friend class RemoteCacheImpl;
+};
+
+}} // namespace
+
+#endif  /* ISPN_HOTROD_REMOTECACHEBASE_H */
diff -Naur old/include/infinispan/hotrod/RemoteCache.h cpp/include/infinispan/hotrod/RemoteCache.h
--- old/include/infinispan/hotrod/RemoteCache.h	1969-12-31 16:00:00.000000000 -0800
+++ cpp/include/infinispan/hotrod/RemoteCache.h	2013-05-22 17:07:12.000000000 -0700
@@ -0,0 +1,66 @@
+#ifndef ISPN_HOTROD_REMOTECACHE_H
+#define ISPN_HOTROD_REMOTECACHE_H
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010 Red Hat Inc. and/or its affiliates and other
+ * contributors as indicated by the @author tags. All rights reserved.
+ * See the copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+#include "infinispan/hotrod/RemoteCacheBase.h"
+#include "infinispan/hotrod/Marshaller.h"
+
+namespace infinispan {
+namespace hotrod {
+
+template <class K, class V>
+class RemoteCache : private RemoteCacheBase
+{
+  public:
+    V get(const K& k) {
+        ScopedBuffer vbuf;
+        base_get(&k, &vbuf);
+        return valueMarshaller->unmarshall(vbuf);
+    }
+    void put(const K& k, const V& v) {
+        base_put(&k, &v);;
+    }
+    // Need separate signature for ForceReturnPreviousValue:   V put(const K& k, const V& v)
+
+  private:
+    RemoteCache() {
+        setMarshallers(this, &keyMarshall, &valueMarshall);
+    }
+    HR_SHARED_PTR<Marshaller<K> > keyMarshaller;
+    HR_SHARED_PTR<Marshaller<V> > valueMarshaller;
+    // type-hiding and resurrecting support
+    static void keyMarshall(void *thisp, const void* key, void* buf) {
+        ((RemoteCache<K, V> *) thisp)->keyMarshaller->marshall(*(K *) key, *(ScopedBuffer *) buf);
+    }
+    static void valueMarshall(void* thisp, const void* val, void* buf) {
+        ((RemoteCache<K, V> *)thisp)->valueMarshaller->marshall(*(V *) val, *(ScopedBuffer *) buf);
+    }
+
+  friend class RemoteCacheManager;
+};
+
+}} // namespace
+
+#endif  /* ISPN_HOTROD_REMOTECACHE_H */
diff -Naur old/include/infinispan/hotrod/RemoteCacheManager.h cpp/include/infinispan/hotrod/RemoteCacheManager.h
--- old/include/infinispan/hotrod/RemoteCacheManager.h	1969-12-31 16:00:00.000000000 -0800
+++ cpp/include/infinispan/hotrod/RemoteCacheManager.h	2013-05-22 17:12:10.000000000 -0700
@@ -0,0 +1,59 @@
+#ifndef ISPN_HOTROD_REMOTECACHEMANAGER_H
+#define ISPN_HOTROD_REMOTECACHEMANAGER_H
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010 Red Hat Inc. and/or its affiliates and other
+ * contributors as indicated by the @author tags. All rights reserved.
+ * See the copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+#include "infinispan/hotrod/ImportExport.h"
+#include "infinispan/hotrod/Handle.h"
+#include "infinispan/hotrod/RemoteCache.h"
+
+//TODO: make the marshaller configurable
+#include "hotrod/sys/BasicMarshaller.h"
+
+namespace infinispan {
+namespace hotrod {
+
+class RemoteCacheManagerImpl;
+
+class HR_EXTERN RemoteCacheManager
+    : public infinispan::hotrod::Handle<RemoteCacheManagerImpl>
+{
+  public:
+    RemoteCacheManager();
+
+    template <class K, class V> RemoteCache<K, V> getCache() {
+        RemoteCache<K, V> rcache;
+        initCache(rcache);
+        rcache.keyMarshaller.reset(new sys::BasicMarshaller<K>());
+        rcache.valueMarshaller.reset(new sys::BasicMarshaller<V>());
+        return rcache;
+    }
+
+  private:
+    void initCache (RemoteCacheBase &cache);
+};
+
+}} // namespace
+
+#endif  /* ISPN_HOTROD_REMOTECACHEMANAGER_H */
diff -Naur old/include/infinispan/hotrod/ScopedBuffer.h cpp/include/infinispan/hotrod/ScopedBuffer.h
--- old/include/infinispan/hotrod/ScopedBuffer.h	1969-12-31 16:00:00.000000000 -0800
+++ cpp/include/infinispan/hotrod/ScopedBuffer.h	2013-05-22 17:12:05.000000000 -0700
@@ -0,0 +1,70 @@
+#ifndef ISPN_HOTROD_SCOPEDBUFFER_H
+#define ISPN_HOTROD_SCOPEDBUFFER_H
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010 Red Hat Inc. and/or its affiliates and other
+ * contributors as indicated by the @author tags. All rights reserved.
+ * See the copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+#include "infinispan/hotrod/exceptions.h"
+
+namespace infinispan {
+namespace hotrod {
+
+/*
+ * A semi-smart ptr object to hold intermediate marshalled data in the
+ * lifetime of a block.  For default case, the bytes are "owned" by
+ * the scope and freed when the dtor is called on block exit.  Not for
+ * general use.  Intended for short lived serialized bytes passed
+ * between a marshaller and Hot Rod.  TODO: better name.
+ */
+
+class ScopedBuffer
+{
+  public:
+    typedef void (*ReleaseFunc)(ScopedBuffer *);
+    ScopedBuffer() : bytes(0), len(0), release(0) {}
+    ~ScopedBuffer() {
+        if (release)
+            (*release)(this);
+        else
+            delete[] bytes;
+    }
+    void set(char *b, size_t l, ReleaseFunc m = 0) {
+        if (bytes || len || release) throw HotRodClientException("ScopedBuffer reuse");
+        bytes = b; len = l; release = m;
+    }
+    char* getBytes() const { return bytes; }
+    size_t getLength() const { return len; }
+    ReleaseFunc getRelease() const { return release; }
+    
+  private:
+    ScopedBuffer(const ScopedBuffer &);
+    ScopedBuffer& operator=(ScopedBuffer const &);
+
+    char* bytes;
+    size_t len;
+    ReleaseFunc release;
+};
+
+}} // namespace
+
+#endif  /* ISPN_HOTROD_SCOPEDBUFFER_H */
diff -Naur old/include/infinispan/hotrod/types.h cpp/include/infinispan/hotrod/types.h
--- old/include/infinispan/hotrod/types.h	1969-12-31 16:00:00.000000000 -0800
+++ cpp/include/infinispan/hotrod/types.h	2013-05-22 07:18:01.000000000 -0700
@@ -0,0 +1,132 @@
+#ifndef ISPN_HOTROD_TYPES_H
+#define ISPN_HOTROD_TYPES_H
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010 Red Hat Inc. and/or its affiliates and other
+ * contributors as indicated by the @author tags. All rights reserved.
+ * See the copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+#include "infinispan/hotrod/ImportExport.h"
+
+// Platform dependent shared_ptr definition.  Todo: more platforms, more elegance.
+#if defined (__GNUC__) && __GNUC__ >= 4 
+    #include <tr1/memory>
+    #define  HR_SHARED_PTR std::tr1::shared_ptr
+#elif defined (_MSC_VER)
+    // TODO: handle multiple VS versions 
+    #include <memory>
+    #define  HR_SHARED_PTR std::tr1::shared_ptr
+#endif
+
+/*
+ * Handle special cases for stdint.h and the definition for ssize_t.
+ * Third party libraries (e.g. Boost) may provide competing solutions.
+ *
+ * The effects of this include file may be controlled by overrides:
+ *  PN_DEFINE_STDINT/PN_NODEFINE_STDINT   : turn on/off definition of int64_t etc.
+ *  PN_DEFINE_SSIZE_T/PN_NODEFINE_SSIZE_T : turn on/off definition of ssize_t
+ *  PN_INCLUDE_STDINT/PN_NOINCLUDE_STDINT : include (or not) stdint.h
+ */
+
+// Honor positive overrides
+#if defined(PN_DEFINE_STDINT)
+#define PNI_DEFINE_STDINT
+#endif
+#if defined(PN_INCLUDE_STDINT)
+#define PNI_INCLUDE_STDINT)
+#endif
+#if defined(PN_DEFINE_SSIZE_T)
+#define PNI_DEFINE_SSIZE_T
+#endif
+
+// Determinine default action
+#ifndef _MSC_VER
+// Not Windows and not using Visual Studio
+#ifndef PNI_INCLUDE_STDINT
+#define PNI_INCLUDE_STDINT
+#endif
+#else
+// all versions of Visual Studio
+#ifndef PNI_DEFINE_SSIZE_T
+// ssie_t def is needed, unless third party definition interferes, e.g. python/swig
+#ifndef Py_CONFIG_H
+#define PNI_DEFINE_SSIZE_T
+#endif
+#endif
+
+#if (_MSC_VER < 1600)
+// VS 2008 and earlier
+#ifndef PNI_DEFINE_STDINT
+#define PNI_DEFINE_STDINT
+#endif
+#else
+// VS 2010 and newer
+#ifndef PNI_INCLUDE_STDINT
+#define PNI_INCLUDE_STDINT
+#endif
+
+#endif // (_MSC_VER < 1600)
+#endif //_MSC_VER
+
+// Honor negative overrides
+#ifdef PN_NODEFINE_SSIZE_T
+#undef PNI_DEFINE_SSIZE_T
+#endif
+#ifdef PN_NODEFINE_STDINT
+#undef PNI_DEFINE_STDINT
+#endif
+#ifdef PN_NOINCLUDE_STDINT
+#undef PNI_INCLUDE_STDINT
+#endif
+
+#ifdef PNI_INCLUDE_STDINT
+#include <stdint.h>
+#endif
+
+#ifdef PNI_DEFINE_SSIZE_T
+#ifdef _MSC_VER
+#include <BaseTsd.h>
+typedef SSIZE_T ssize_t;
+#else
+#error ssize_t definition not kown
+#endif
+#endif // PNI_DEFINE_SSIZE_T
+
+#ifdef PNI_DEFINE_STDINT
+#ifdef _MSC_VER
+
+typedef signed __int8 int8_t;
+typedef signed __int16 int16_t;
+typedef signed __int32 int32_t;
+typedef signed __int64 int64_t;
+
+typedef unsigned __int8 uint8_t;
+typedef unsigned __int16 uint16_t;
+typedef unsigned __int32 uint32_t;
+typedef unsigned __int64 uint64_t;
+
+#else // _MSC_VER
+#error stdint.h definitions not kown
+#endif
+#endif // PNI_DEFINE_SSIZE_T
+
+
+#endif  /* ISPN_HOTROD_TYPES_H */
diff -Naur old/src/hotrod/api/exceptions.cpp cpp/src/hotrod/api/exceptions.cpp
--- old/src/hotrod/api/exceptions.cpp	1969-12-31 16:00:00.000000000 -0800
+++ cpp/src/hotrod/api/exceptions.cpp	2013-05-17 09:11:45.000000000 -0700
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010 Red Hat Inc. and/or its affiliates and other
+ * contributors as indicated by the @author tags. All rights reserved.
+ * See the copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+#include "infinispan/hotrod/exceptions.h"
+
+namespace infinispan {
+namespace hotrod {
+
+Exception::Exception(const std::string& msg) throw() : message(msg) {}
+Exception::~Exception() throw() {}
+const char* Exception::what() const throw() { return message.c_str(); }
+
+HotRodClientException::HotRodClientException(const std::string& msg) : Exception(msg) {}
+
+TransportException::TransportException(const std::string& msg) : Exception(msg) {}
+
+}} /* namespace */
diff -Naur old/src/hotrod/api/RemoteCacheBase.cpp cpp/src/hotrod/api/RemoteCacheBase.cpp
--- old/src/hotrod/api/RemoteCacheBase.cpp	1969-12-31 16:00:00.000000000 -0800
+++ cpp/src/hotrod/api/RemoteCacheBase.cpp	2013-05-22 07:18:33.000000000 -0700
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010 Red Hat Inc. and/or its affiliates and other
+ * contributors as indicated by the @author tags. All rights reserved.
+ * See the copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+#include "infinispan/hotrod/RemoteCacheBase.h"
+#include "hotrod/impl/RemoteCacheImpl.h"
+
+namespace infinispan {
+namespace hotrod {
+
+RemoteCacheBase::RemoteCacheBase() : 
+    Handle<RemoteCacheImpl>(new RemoteCacheImpl(*this)) {}
+    
+void RemoteCacheBase::setMarshallers(void* rc, MarshallHelperFn kf, MarshallHelperFn vf) {
+    remoteCachePtr = rc;
+    baseKeyMarshallFn = kf;
+    baseValueMarshallFn = vf;
+}
+    
+void RemoteCacheBase::baseKeyMarshall(const void* k, void *buf) {
+    baseKeyMarshallFn(remoteCachePtr, k, buf);
+}
+
+void RemoteCacheBase::baseValueMarshall(const void* v, void *buf) {
+    baseValueMarshallFn(remoteCachePtr, v, buf);
+}
+
+void RemoteCacheBase::base_get(const void *key, void *buf) {
+    impl->get(key, buf);
+}
+
+void RemoteCacheBase::base_put(const void *key, const void *val) {
+    impl->put(key, val);
+}
+
+}} /* namespace */
diff -Naur old/src/hotrod/api/RemoteCacheManager.cpp cpp/src/hotrod/api/RemoteCacheManager.cpp
--- old/src/hotrod/api/RemoteCacheManager.cpp	1969-12-31 16:00:00.000000000 -0800
+++ cpp/src/hotrod/api/RemoteCacheManager.cpp	2013-05-20 08:20:10.000000000 -0700
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010 Red Hat Inc. and/or its affiliates and other
+ * contributors as indicated by the @author tags. All rights reserved.
+ * See the copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+#include "infinispan/hotrod/RemoteCacheManager.h"
+#include "hotrod/impl/RemoteCacheManagerImpl.h"
+
+namespace infinispan {
+namespace hotrod {
+
+RemoteCacheManager::RemoteCacheManager() : 
+    Handle<RemoteCacheManagerImpl>(new RemoteCacheManagerImpl()) {}
+    
+    void RemoteCacheManager::initCache (RemoteCacheBase &/*cache*/) {}
+
+}} /* namespace */
diff -Naur old/src/hotrod/impl/operations/GetOperation.cpp cpp/src/hotrod/impl/operations/GetOperation.cpp
--- old/src/hotrod/impl/operations/GetOperation.cpp	1969-12-31 16:00:00.000000000 -0800
+++ cpp/src/hotrod/impl/operations/GetOperation.cpp	2013-05-22 17:15:47.000000000 -0700
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010 Red Hat Inc. and/or its affiliates and other
+ * contributors as indicated by the @author tags. All rights reserved.
+ * See the copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+#include "hotrod/sys/types.h"
+#include "hotrod/impl/operations/GetOperation.h"
+#include <cstring>
+
+namespace infinispan {
+namespace hotrod {
+namespace operations {
+
+//    GetOperation::sendKeyOperation(ScopedBuffer& key, Transport& transport, byte opCode, byte opRespCode);
+GetOperation::GetOperation(hrbytes& k, hrbytes& cn) : transport(Transport::getTestTransport()),
+ keyName(k), cacheName(cn) {}
+
+hrbytes GetOperation::execute() {
+    return transport.strawGet(keyName);
+}
+
+
+}}} /* namespace */
diff -Naur old/src/hotrod/impl/operations/GetOperation.h cpp/src/hotrod/impl/operations/GetOperation.h
--- old/src/hotrod/impl/operations/GetOperation.h	1969-12-31 16:00:00.000000000 -0800
+++ cpp/src/hotrod/impl/operations/GetOperation.h	2013-05-22 17:14:07.000000000 -0700
@@ -0,0 +1,60 @@
+#ifndef ISPN_HOTROD_GETOPERATION_H
+#define ISPN_HOTROD_GETOPERATION_H
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010 Red Hat Inc. and/or its affiliates and other
+ * contributors as indicated by the @author tags. All rights reserved.
+ * See the copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+#include "infinispan/hotrod/types.h"
+#include "infinispan/hotrod/ScopedBuffer.h"
+#include "infinispan/hotrod/RemoteCacheBase.h"
+#include "hotrod/impl/transport/Transport.h"
+
+namespace infinispan {
+namespace hotrod {
+namespace operations {
+
+// Java: public class GetOperation extends AbstractKeyOperation<byte[]> {...}
+// straw man implementation here:
+
+using namespace infinispan::hotrod::sys;
+
+class GetOperation
+{
+  public:
+//    void executeOperation(Transport& t, ScopedBuffer& r) : transport(t), result(r);
+    hrbytes execute();
+                 
+//  protected:
+//    sendKeyOperation(ScopedBuffer& key, Transport& transport, char opCode, char opRespCode);
+  private:
+    GetOperation(hrbytes& k, hrbytes& cacheName);
+    Transport& transport;
+    hrbytes& keyName;
+    hrbytes& cacheName;
+
+    friend class OperationsFactory;
+};
+
+}}} // namespace
+
+#endif  /* ISPN_HOTROD_GETOPERATION_H */
diff -Naur old/src/hotrod/impl/operations/OperationsFactory.cpp cpp/src/hotrod/impl/operations/OperationsFactory.cpp
--- old/src/hotrod/impl/operations/OperationsFactory.cpp	1969-12-31 16:00:00.000000000 -0800
+++ cpp/src/hotrod/impl/operations/OperationsFactory.cpp	2013-05-22 17:18:53.000000000 -0700
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010 Red Hat Inc. and/or its affiliates and other
+ * contributors as indicated by the @author tags. All rights reserved.
+ * See the copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+#include "hotrod/sys/types.h"
+#include "hotrod/impl/operations/OperationsFactory.h"
+#include <cstring>
+
+namespace infinispan {
+namespace hotrod {
+namespace operations {
+
+using namespace infinispan::hotrod::sys;
+
+OperationsFactory::OperationsFactory() {}
+
+hrbytes OperationsFactory::cacheName(0,0);
+OperationsFactory* OperationsFactory::testFactory = 0;
+OperationsFactory& OperationsFactory::getTestFactory() {
+    if (!testFactory) {
+        testFactory = new OperationsFactory();
+        cacheName.reserve(6);
+        memcpy(cacheName.bytes(), "foobar", 6); // not used yet
+    }
+    return *testFactory;
+}
+
+GetOperation* OperationsFactory::newGetKeyOperation(hrbytes& key) {
+    return new GetOperation(key, cacheName);
+}
+
+PutOperation* OperationsFactory::newPutKeyValueOperation(hrbytes& key, hrbytes& value) {
+    return new PutOperation(key, value, cacheName);
+}
+
+
+}}} /* namespace */
diff -Naur old/src/hotrod/impl/operations/OperationsFactory.h cpp/src/hotrod/impl/operations/OperationsFactory.h
--- old/src/hotrod/impl/operations/OperationsFactory.h	1969-12-31 16:00:00.000000000 -0800
+++ cpp/src/hotrod/impl/operations/OperationsFactory.h	2013-05-16 20:36:11.000000000 -0700
@@ -0,0 +1,54 @@
+#ifndef ISPN_HOTROD_OPERATIONSFACTORY_H
+#define ISPN_HOTROD_OPERATIONSFACTORY_H
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010 Red Hat Inc. and/or its affiliates and other
+ * contributors as indicated by the @author tags. All rights reserved.
+ * See the copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+#include "hotrod/sys/types.h"
+#include "hotrod/impl/operations/GetOperation.h"
+#include "hotrod/impl/operations/PutOperation.h"
+
+namespace infinispan {
+namespace hotrod {
+namespace operations {
+
+
+
+class OperationsFactory
+{
+  private:
+    static OperationsFactory* testFactory;
+  public:
+    static OperationsFactory& getTestFactory();
+    static hrbytes cacheName;
+    PutOperation* newPutKeyValueOperation(hrbytes& key, hrbytes& value);
+    GetOperation* newGetKeyOperation(hrbytes& key);
+
+  private:
+    OperationsFactory();
+};
+
+}}} // namespace
+
+#endif  /* ISPN_HOTROD_OPERATIONSFACTORY_H */
+
diff -Naur old/src/hotrod/impl/operations/PutOperation.cpp cpp/src/hotrod/impl/operations/PutOperation.cpp
--- old/src/hotrod/impl/operations/PutOperation.cpp	1969-12-31 16:00:00.000000000 -0800
+++ cpp/src/hotrod/impl/operations/PutOperation.cpp	2013-05-17 12:45:18.000000000 -0700
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010 Red Hat Inc. and/or its affiliates and other
+ * contributors as indicated by the @author tags. All rights reserved.
+ * See the copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+#include "hotrod/sys/types.h"
+#include "hotrod/impl/operations/PutOperation.h"
+#include <cstring>
+
+namespace infinispan {
+namespace hotrod {
+namespace operations {
+
+PutOperation::PutOperation(hrbytes& k, hrbytes& v, hrbytes& cn) : transport(Transport::getTestTransport()),
+                keyBytes(k), valueBytes(v), cacheName(cn) {}
+
+void PutOperation::execute() {
+    transport.strawPut(keyBytes, valueBytes);
+}
+
+
+}}} /* namespace */
diff -Naur old/src/hotrod/impl/operations/PutOperation.h cpp/src/hotrod/impl/operations/PutOperation.h
--- old/src/hotrod/impl/operations/PutOperation.h	1969-12-31 16:00:00.000000000 -0800
+++ cpp/src/hotrod/impl/operations/PutOperation.h	2013-05-21 12:55:11.000000000 -0700
@@ -0,0 +1,54 @@
+#ifndef ISPN_HOTROD_PUTOPERATION_H
+#define ISPN_HOTROD_PUTOPERATION_H
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010 Red Hat Inc. and/or its affiliates and other
+ * contributors as indicated by the @author tags. All rights reserved.
+ * See the copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+#include "infinispan/hotrod/types.h"
+#include "hotrod/impl/transport/Transport.h"
+
+namespace infinispan {
+namespace hotrod {
+namespace operations {
+
+// straw man implementation here:
+
+using namespace infinispan::hotrod::sys;
+
+class PutOperation
+{
+  public:
+    void execute();
+  private:
+    PutOperation(hrbytes& k, hrbytes& v, hrbytes& cacheName);
+    Transport& transport;
+    hrbytes& keyBytes;
+    hrbytes& valueBytes;
+    hrbytes& cacheName;
+
+    friend class OperationsFactory;
+};
+
+}}} // namespace
+
+#endif  /* ISPN_HOTROD_PUTOPERATION_H */
diff -Naur old/src/hotrod/impl/RemoteCacheImpl.cpp cpp/src/hotrod/impl/RemoteCacheImpl.cpp
--- old/src/hotrod/impl/RemoteCacheImpl.cpp	1969-12-31 16:00:00.000000000 -0800
+++ cpp/src/hotrod/impl/RemoteCacheImpl.cpp	2013-05-22 07:39:08.000000000 -0700
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010 Red Hat Inc. and/or its affiliates and other
+ * contributors as indicated by the @author tags. All rights reserved.
+ * See the copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+#include "hotrod/sys/types.h"
+#include "hotrod/impl/RemoteCacheImpl.h"
+#include "hotrod/impl/operations/OperationsFactory.h"
+#include "hotrod/impl/operations/GetOperation.h"
+
+#include <iostream>
+
+namespace infinispan {
+namespace hotrod {
+
+using namespace operations;
+using namespace sys;
+
+RemoteCacheImpl::RemoteCacheImpl(RemoteCacheBase& base)
+    :remoteCacheBase(base), operationsFactory(OperationsFactory::getTestFactory()) {}
+
+
+void RemoteCacheImpl::get(const void *k, void* b) {
+    ScopedBuffer kbuf;
+    ScopedBuffer& vbuf(*(ScopedBuffer *)b);
+    remoteCacheBase.baseKeyMarshall(k, &kbuf);
+    hrbytes keyBytes(kbuf.getBytes(), kbuf.getLength());
+
+    hr_scoped_ptr<GetOperation> gco(operationsFactory.newGetKeyOperation(keyBytes));
+    hrbytes bytes = gco->execute();
+    bytes.releaseTo(vbuf);
+}
+
+void RemoteCacheImpl::put(const void *k, const void* v) {
+    ScopedBuffer kbuf, vbuf;
+    remoteCacheBase.baseKeyMarshall(k, &kbuf);
+    remoteCacheBase.baseValueMarshall(v, &vbuf);
+    hrbytes keyBytes(kbuf.getBytes(), kbuf.getLength());
+    hrbytes valueBytes(vbuf.getBytes(), vbuf.getLength());
+
+    hr_scoped_ptr<PutOperation> op(operationsFactory.newPutKeyValueOperation(keyBytes, valueBytes));
+    op->execute();
+}
+
+}} /* namespace */
diff -Naur old/src/hotrod/impl/RemoteCacheImpl.h cpp/src/hotrod/impl/RemoteCacheImpl.h
--- old/src/hotrod/impl/RemoteCacheImpl.h	1969-12-31 16:00:00.000000000 -0800
+++ cpp/src/hotrod/impl/RemoteCacheImpl.h	2013-05-22 07:39:34.000000000 -0700
@@ -0,0 +1,51 @@
+#ifndef ISPN_HOTROD_REMOTECACHEIMPL_H
+#define ISPN_HOTROD_REMOTECACHEIMPL_H
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010 Red Hat Inc. and/or its affiliates and other
+ * contributors as indicated by the @author tags. All rights reserved.
+ * See the copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+#include "infinispan/hotrod/types.h"
+#include "infinispan/hotrod/ScopedBuffer.h"
+#include "infinispan/hotrod/RemoteCacheBase.h"
+#include "hotrod/impl/operations/OperationsFactory.h"
+
+namespace infinispan {
+namespace hotrod {
+
+using namespace operations;
+
+class RemoteCacheImpl
+{
+  public:
+    RemoteCacheImpl(RemoteCacheBase& basexx);
+    void get(const void* key, void *buf);
+    void put(const void* key, const void* val);
+  private:
+    RemoteCacheBase& remoteCacheBase;
+    OperationsFactory& operationsFactory;
+};
+
+}} // namespace
+
+#endif  /* ISPN_HOTROD_REMOTECACHEIMPL_H */
+
diff -Naur old/src/hotrod/impl/RemoteCacheManagerImpl.cpp cpp/src/hotrod/impl/RemoteCacheManagerImpl.cpp
--- old/src/hotrod/impl/RemoteCacheManagerImpl.cpp	1969-12-31 16:00:00.000000000 -0800
+++ cpp/src/hotrod/impl/RemoteCacheManagerImpl.cpp	2013-05-13 23:01:41.000000000 -0700
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010 Red Hat Inc. and/or its affiliates and other
+ * contributors as indicated by the @author tags. All rights reserved.
+ * See the copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+#include "hotrod/impl/RemoteCacheManagerImpl.h"
+#include <iostream>
+
+#include "infinispan/hotrod/ImportExport.h"
+#include "infinispan/hotrod/ScopedBuffer.h"
+#include "hotrod/sys/BasicMarshaller.h"
+
+namespace infinispan {
+namespace hotrod {
+
+
+using namespace infinispan::hotrod;
+
+
+}} /* namespace */
diff -Naur old/src/hotrod/impl/RemoteCacheManagerImpl.h cpp/src/hotrod/impl/RemoteCacheManagerImpl.h
--- old/src/hotrod/impl/RemoteCacheManagerImpl.h	1969-12-31 16:00:00.000000000 -0800
+++ cpp/src/hotrod/impl/RemoteCacheManagerImpl.h	2013-05-09 13:00:46.000000000 -0700
@@ -0,0 +1,36 @@
+#ifndef ISPN_HOTROD_REMOTECACHEMANAGERIMPL_H
+#define ISPN_HOTROD_REMOTECACHEMANAGERIMPL_H
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010 Red Hat Inc. and/or its affiliates and other
+ * contributors as indicated by the @author tags. All rights reserved.
+ * See the copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+namespace infinispan {
+namespace hotrod {
+
+class RemoteCacheManagerImpl
+{
+};
+
+}} // namespace
+
+#endif  /* ISPN_HOTROD_REMOTECACHEMANAGERIMPL_H */
diff -Naur old/src/hotrod/impl/transport/Transport.cpp cpp/src/hotrod/impl/transport/Transport.cpp
--- old/src/hotrod/impl/transport/Transport.cpp	1969-12-31 16:00:00.000000000 -0800
+++ cpp/src/hotrod/impl/transport/Transport.cpp	2013-05-22 17:20:25.000000000 -0700
@@ -0,0 +1,243 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010 Red Hat Inc. and/or its affiliates and other
+ * contributors as indicated by the @author tags. All rights reserved.
+ * See the copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+#include "infinispan/hotrod/exceptions.h"
+#include "hotrod/impl/transport/Transport.h"
+
+#include <iostream>
+#include <cstring>
+#include <istream>
+#include <sstream>
+
+
+namespace infinispan {
+namespace hotrod {
+
+namespace {
+
+static int pinged = 0;
+
+char* check_header(char *resp, uint8_t expected_op) {
+    if ((unsigned char)resp[0] != 0xA1)
+        throw HotRodClientException("bad magic");
+    if (resp[1] != 0)
+        throw HotRodClientException("message id parsing missing");
+    if (resp[2] != expected_op)
+        throw HotRodClientException("wrong message response");
+    if (resp[3] == 2)
+        throw HotRodClientException("Key not found");
+    if (resp[3] != 0)
+        throw HotRodClientException("straw man falls down");
+    if (resp[4] != 0)
+        throw HotRodClientException("straw man falls flat");
+    return resp+5;
+}
+
+int32_t readUnsignedInt(std::stringstream& in) {
+    char b;
+    in.get(b);
+    int32_t i = b & 0x7F;
+    for (int shift = 7; (b & 0x80) != 0; shift += 7) {
+        in.get(b);
+        i |= (b & 0x7FL) << shift;
+    }
+    return i;
+}
+
+int64_t readUnsignedLong(std::stringstream& in) {
+    char b;
+    in.get(b);
+    int64_t i = b & 0x7F;
+    for (int shift = 7; (b & 0x80) != 0; shift += 7) {
+        in.get(b);
+        i |= (b & 0x7FL) << shift;
+    }
+    return i;
+}
+
+void writeUnsignedInt(std::stringstream& out, int32_t i) {
+    while ((i & ~0x7F) != 0) {
+        char b = (i & 0x7f) | 0x80;
+        out.put(b);
+        i >>= 7;
+    }
+    out.put((char) i);
+}
+
+void writeUnsignedLong(std::stringstream& out, int64_t i) {
+    while ((i & ~0x7F) != 0) {
+        char b = (i & 0x7f) | 0x80;
+        out.put(b);
+        i >>= 7;
+    }
+    out.put((char) i);
+}
+
+
+int32_t readUnsignedInt(char*& input) {
+    char b = *input++;
+    int32_t i = b & 0x7F;
+    for (int shift = 7; (b & 0x80) != 0; shift += 7) {
+        b = *input++;
+        i |= (b & 0x7FL) << shift;
+    }
+    return i;
+}
+
+int64_t readUnsignedLong(char*& input) {
+    char b = *input++;
+    int64_t i = b & 0x7F;
+    for (int shift = 7; (b & 0x80) != 0; shift += 7) {
+        b = *input++;
+        i |= (b & 0x7FL) << shift;
+    }
+    return i;
+}
+
+void writeUnsignedInt(char*& output, int32_t i) {
+    while ((i & ~0x7F) != 0) {
+        *output++ = (char) ((i & 0x7f) | 0x80);
+        i >>= 7;
+    }
+    *output++ = (char) i;
+}
+
+void writeUnsignedLong(char*& output, int64_t i) {
+    while ((i & ~0x7F) != 0) {
+        *output++ = (char) ((i & 0x7f) | 0x80);
+        i >>= 7;
+    }
+    *output++ = (char) i;
+}
+
+} /* namespace */
+
+
+Transport::Transport() : socket(sys::Socket::create()) {socket->connect();}
+
+Transport* Transport::testTransport = 0;
+Transport& Transport::getTestTransport() {
+    if (!testTransport)
+        testTransport = new Transport();
+    return *testTransport;
+}
+
+
+void Transport::strawPing() {
+    std::stringstream ss;
+
+    ss.put((char) 0xA0);
+    writeUnsignedLong(ss, 0);
+    ss.put((char)12);
+    ss.put((char) 0x17);
+    writeUnsignedInt(ss, 0);
+    writeUnsignedInt(ss, 0);
+    ss.put((char) 0x1);
+    writeUnsignedInt(ss, 0);
+    ss.put((char) 0);
+
+    std::string outstr(ss.str());
+    socket->write(outstr.data(), outstr.size());
+    char buf[1024];
+    socket->read(buf, 1024);
+    check_header(buf, 0x18);
+}
+
+
+hrbytes Transport::strawGet(hrbytes& k) {
+    std::stringstream ss;
+    // header
+    ss.put((char) 0xA0);
+    writeUnsignedLong(ss, 0);
+    ss.put((char)12);
+    ss.put((char) 0x03); // get
+    writeUnsignedInt(ss, 0);
+    writeUnsignedInt(ss, 0);
+    ss.put((char) 0x1);
+    writeUnsignedInt(ss, 0);
+    ss.put((char) 0);
+
+    //get args
+    writeUnsignedInt(ss, k.length());
+    ss.write(k.bytes(), k.length());
+    
+    std::string buf2(ss.str());
+    socket->write(buf2.data(), buf2.size());
+
+    char buf[1024];
+    unsigned int bufsize = sizeof(buf);
+    size_t n = socket->read(buf, bufsize);
+    if (n < 5)
+        throw HotRodClientException("read error");  // header minimum
+    if (n >= 1024) {
+        while (socket->read(buf, bufsize) == bufsize)
+            ;                   // drain
+        throw HotRodClientException("too big for now");
+        // TODO: move buffer contents to return value and read rest
+        // into it from socket directly
+    }
+        
+    char *resp = check_header(buf, 0x4);
+    uint64_t size = readUnsignedLong(resp);
+    hrbytes rv;
+    rv.reserve(size);
+    memcpy(rv.bytes(), resp, size);
+    return rv;
+}
+
+void Transport::strawPut(hrbytes& k, hrbytes& v) {
+    if (!pinged) {
+        pinged = 1;
+        strawPing();
+    }
+
+    std::stringstream ss;
+    // header
+    ss.put((char) 0xA0);
+    writeUnsignedLong(ss, 0);
+    ss.put((char)12);
+    ss.put((char) 0x01); // put
+    writeUnsignedInt(ss, 0);
+    writeUnsignedInt(ss, 0);
+    ss.put((char) 0x1);
+    writeUnsignedInt(ss, 0);
+    ss.put((char) 0);
+
+    //put args
+    writeUnsignedInt(ss, k.length());
+    ss.write(k.bytes(), k.length());
+    writeUnsignedInt(ss, 0);
+    writeUnsignedInt(ss, 0);
+    writeUnsignedInt(ss, v.length());
+    ss.write(v.bytes(), v.length());
+    
+    std::string buf2(ss.str());
+    socket->write(buf2.data(), buf2.size());
+
+    char buf[1024];
+    socket->read(buf, 1024);
+    check_header(buf, 0x2);
+}
+
+
+}} /* namespace */
diff -Naur old/src/hotrod/impl/transport/Transport.h cpp/src/hotrod/impl/transport/Transport.h
--- old/src/hotrod/impl/transport/Transport.h	1969-12-31 16:00:00.000000000 -0800
+++ cpp/src/hotrod/impl/transport/Transport.h	2013-05-22 07:29:24.000000000 -0700
@@ -0,0 +1,52 @@
+#ifndef ISPN_HOTROD_TRANSPORT_H
+#define ISPN_HOTROD_TRANSPORT_H
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010 Red Hat Inc. and/or its affiliates and other
+ * contributors as indicated by the @author tags. All rights reserved.
+ * See the copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+#include "hotrod/sys/types.h"
+#include "hotrod/sys/Socket.h"
+
+namespace infinispan {
+namespace hotrod {
+
+// straw man implementation here:
+
+class Transport
+{
+  private:
+    static Transport* testTransport;
+  public:
+    static Transport& getTestTransport();
+    void strawPing();
+    hrbytes strawGet(hrbytes& k);
+    void strawPut(hrbytes& k, hrbytes& v);
+  private:
+    Transport();
+    HR_SHARED_PTR<sys::Socket> socket;
+};
+
+}} // namespace
+
+#endif  /* ISPN_HOTROD_TRANSPORT_H */
+
diff -Naur old/src/hotrod/sys/BasicMarshaller.h cpp/src/hotrod/sys/BasicMarshaller.h
--- old/src/hotrod/sys/BasicMarshaller.h	1969-12-31 16:00:00.000000000 -0800
+++ cpp/src/hotrod/sys/BasicMarshaller.h	2013-05-22 17:13:50.000000000 -0700
@@ -0,0 +1,64 @@
+#ifndef ISPN_HOTROD_BASICMARSHALLER_H
+#define ISPN_HOTROD_BASICMARSHALLER_H
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010 Red Hat Inc. and/or its affiliates and other
+ * contributors as indicated by the @author tags. All rights reserved.
+ * See the copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+#include <string>
+#include "infinispan/hotrod/Marshaller.h"
+
+namespace infinispan {
+namespace hotrod {
+namespace sys {
+
+/*
+ * A Marshaller for a few simple types.
+ */
+
+
+template <class T> class BasicMarshaller : public infinispan::hotrod::Marshaller<T>
+{
+};
+
+class BasicMarshallerHelper {
+  public:
+    static void noRelease(ScopedBuffer*) { /* nothing allocated, nothing to release */ }
+};
+
+
+// Specialization for std::string:
+
+template <>
+class BasicMarshaller<std::string> : public infinispan::hotrod::Marshaller<std::string> {
+  public:
+    void marshall(const std::string& s, ScopedBuffer& b) {
+        b.set(const_cast<char *> (s.data()), s.size(), &BasicMarshallerHelper::noRelease);
+    }
+    std::string unmarshall(const ScopedBuffer& b) {
+        std::string s(b.getBytes(), b.getLength());
+        return s;
+    }
+};
+
+}}} // namespace
+
+#endif  /* ISPN_HOTROD_BASICMARSHALLER_H */
diff -Naur old/src/hotrod/sys/posix/Socket.cpp cpp/src/hotrod/sys/posix/Socket.cpp
--- old/src/hotrod/sys/posix/Socket.cpp	1969-12-31 16:00:00.000000000 -0800
+++ cpp/src/hotrod/sys/posix/Socket.cpp	2013-05-22 17:13:37.000000000 -0700
@@ -0,0 +1,137 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010 Red Hat Inc. and/or its affiliates and other
+ * contributors as indicated by the @author tags. All rights reserved.
+ * See the copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+#include "infinispan/hotrod/exceptions.h"
+#include "hotrod/sys/Socket.h"
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <string>
+
+#include <errno.h>
+#include <stdexcept>
+#include <string.h>
+
+#include <iostream>
+#include <istream>
+#include <sstream>
+
+namespace infinispan {
+namespace hotrod {
+namespace sys {
+
+// Part of a straw man IO layer
+
+
+
+namespace posix {
+
+class Socket: public infinispan::hotrod::sys::Socket {
+  public:
+    Socket();
+    virtual void connect();
+    virtual void close();
+    virtual size_t read(char *p, size_t n);
+    virtual void write(const char *p, size_t n);
+  private:
+    int fd;
+};
+
+namespace {
+// TODO: centralized hotrod exceptions file name + line number
+void throwIOErr (const char *msg, int errnum) {
+    std::string m(msg);
+    if (errno != 0) {
+        char buf[200];
+        if (strerror_r(errnum, buf, 200) == 0) {
+            m += " ";
+            m += buf;
+        }
+        else {
+            m += " ";
+            m += strerror(errnum);
+        }
+    }
+    throw TransportException(m);
+}
+
+} /* namespace */
+
+Socket::Socket() : fd(-1) {}
+
+void Socket::connect() {
+    if (fd != -1) throwIOErr("reconnect attempt", 0);
+    int sock = socket(AF_INET, SOCK_STREAM, getprotobyname("tcp")->p_proto);
+    if (sock == -1) throwIOErr("connect", errno);
+
+    struct addrinfo *addr;
+    int ec = getaddrinfo("127.0.0.1", "11222", NULL, &addr);
+    if (ec) throwIOErr("getaddrinfo", errno);
+
+    while (::connect(sock, addr->ai_addr, addr->ai_addrlen) == -1) {
+        if (errno != EINPROGRESS) {
+            freeaddrinfo(addr);
+            close();
+            throwIOErr("connect2", errno);
+        }
+    }
+
+    freeaddrinfo(addr);
+    fd = sock;
+}
+
+void Socket::close() {
+    ::close(fd);
+    fd = -1;
+}
+
+size_t Socket::read(char *p, size_t length) {
+    while(1) {
+        ssize_t n =  recv(fd, p, length, 0);
+        if (n < 0 && errno != EAGAIN)
+            throwIOErr("read", errno);
+        else if (n == 0)
+            return 0;
+        else
+            return n;
+    }
+}
+
+void Socket::write(const char *p, size_t length) {
+    ssize_t n = send(fd, p, length, MSG_NOSIGNAL);
+    if (n == -1) throwIOErr ("write", errno);
+    if ((size_t) n != length) throwIOErr ("write error", 0);
+}
+
+} /* posix namespace */
+
+
+Socket* Socket::create() {
+    return new posix::Socket();
+}
+
+}}} /* namespace */
diff -Naur old/src/hotrod/sys/Socket.h cpp/src/hotrod/sys/Socket.h
--- old/src/hotrod/sys/Socket.h	1969-12-31 16:00:00.000000000 -0800
+++ cpp/src/hotrod/sys/Socket.h	2013-05-16 02:09:14.000000000 -0700
@@ -0,0 +1,46 @@
+#ifndef ISPN_HOTROD_SYS_SOCKET_H
+#define ISPN_HOTROD_SYS_SOCKET_H
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010 Red Hat Inc. and/or its affiliates and other
+ * contributors as indicated by the @author tags. All rights reserved.
+ * See the copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+#include "infinispan/hotrod/types.h"
+
+namespace infinispan {
+namespace hotrod {
+namespace sys {
+
+class Socket
+{
+  public:
+    static Socket* create();
+
+    virtual void connect() = 0;
+    virtual void close() = 0;
+    virtual size_t read(char *p, size_t n) = 0;
+    virtual void write(const char *p, size_t n) = 0;
+};
+
+}}} // namespace
+
+#endif  /* ISPN_HOTROD_SYS_SOCKET_H */
diff -Naur old/src/hotrod/sys/types.h cpp/src/hotrod/sys/types.h
--- old/src/hotrod/sys/types.h	1969-12-31 16:00:00.000000000 -0800
+++ cpp/src/hotrod/sys/types.h	2013-05-22 17:13:29.000000000 -0700
@@ -0,0 +1,158 @@
+#ifndef ISPN_HOTROD_SYS_TYPES_H
+#define ISPN_HOTROD_SYS_TYPES_H
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010 Red Hat Inc. and/or its affiliates and other
+ * contributors as indicated by the @author tags. All rights reserved.
+ * See the copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+#include "infinispan/hotrod/types.h"
+#include "infinispan/hotrod/ScopedBuffer.h"
+
+#include <exception>
+#include <memory>
+#include <iostream>
+
+namespace infinispan {
+namespace hotrod {
+
+/*
+ * A limited functionality scoped_ptr.  Defined here because auto_ptr
+ * deprecated, unique_ptr too new, shared_ptr too heavy, and boost not
+ * available.  Main use is to allow C++ code to resemble the original
+ * Java code in program flow for short lived objects.  Replace with
+ * another solution if it instead promotes contorted code.
+ *
+ * Single use, non-copyable.
+ */
+
+template <class T> class hr_scoped_ptr {
+ public:
+    hr_scoped_ptr (T* p) : px(p) {
+        // TODO: replace with hotrod exception
+        if (!p) throw std::exception();
+    }
+    ~hr_scoped_ptr() { delete(px); }
+
+    T& operator*() {return *px ; }
+    T* operator->() { return px; }
+
+  private:
+    hr_scoped_ptr(hr_scoped_ptr const &);
+    hr_scoped_ptr& operator=(hr_scoped_ptr const &);
+
+    T* px;
+};
+
+
+/*
+ * A Java byte[] substitute class.  Can be toggled smart or dumb.  Not
+ * to be exposed as a public interface.  More performant version
+ * surely possible.  Hopefully efficient with return value
+ * optimization based on observed frequent use of Java code:
+ *
+ *   byte[] result = foo();
+ *
+ * Basic use: 
+ *   hrbyes mybytes(addr, len); // no ownership
+ *
+ *   mybytes.setSmart(new char[len], len); // ownership
+ *   mybytes.reserve(len);      // same as line above
+ *
+ * TODO: move to auto_ptr/unique_ptr platform neutral implementation
+ * (good), add support to work with a buffer pool (better).
+ *
+ */
+
+class hrbytes {
+ public:
+    struct HrbDeleter {
+        void operator()(char* p) {
+            if (p == 0) {
+                // called via get_deleter from below
+                disabled = true;
+                return;
+            }
+                
+            if (!disabled) {
+                delete[] p;
+            }
+        }
+        bool disabled;
+    };
+
+    unsigned int length() { return len; }
+    char* bytes() { return dumbBytes ? dumbBytes : smartBytes.get(); }
+
+    hrbytes() : dumbBytes(0), len(0) {}
+    hrbytes(char *b, unsigned int l) :  dumbBytes(b), len(l) {}
+
+    void set(char *b, unsigned int l) {
+        smartBytes.reset();
+        len = l;
+        dumbBytes = b;
+    }
+    void setSmart(char *b, unsigned int l) {
+        smartBytes.reset(b, HrbDeleter());
+        len = l;
+        dumbBytes = 0;
+    }
+    void reserve(unsigned int l) {
+        dumbBytes = 0;
+        len = l;
+        smartBytes.reset(new char[len], HrbDeleter());
+    }
+
+    hrbytes(hrbytes const &other) {
+        len = other.len;
+        dumbBytes = other.dumbBytes;
+        smartBytes = other.smartBytes;
+        if (!dumbBytes) other.dumbBytes = smartBytes.get();
+    }
+    hrbytes& operator=(hrbytes const &other) {
+        len = other.len;
+        dumbBytes = other.dumbBytes;
+        smartBytes = other.smartBytes;
+        if (!dumbBytes) other.dumbBytes = smartBytes.get();
+        return *this;
+    }
+        
+    static void delayedDelete (ScopedBuffer *buf) {
+        delete[] buf->getBytes();
+    }
+    void releaseTo(ScopedBuffer& buf) {
+        // TODO: assert smartBytes.unique()
+        if (dumbBytes)
+            buf.set(dumbBytes, len);
+        else {
+            buf.set(smartBytes.get(), len, &delayedDelete);
+            (*std::tr1::get_deleter<HrbDeleter>(smartBytes))(0);
+        }
+    }
+  private:
+    mutable char* dumbBytes;
+    unsigned int len;
+    HR_SHARED_PTR<char> smartBytes;
+};
+    
+}}
+
+#endif  /* ISPN_HOTROD_SYS_TYPES_H */
diff -Naur old/src/hotrod/sys/windows/Socket.cpp cpp/src/hotrod/sys/windows/Socket.cpp
--- old/src/hotrod/sys/windows/Socket.cpp	1969-12-31 16:00:00.000000000 -0800
+++ cpp/src/hotrod/sys/windows/Socket.cpp	2013-05-22 17:13:45.000000000 -0700
@@ -0,0 +1,138 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010 Red Hat Inc. and/or its affiliates and other
+ * contributors as indicated by the @author tags. All rights reserved.
+ * See the copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+#include "infinispan/hotrod/exceptions.h"
+#include "hotrod/sys/Socket.h"
+
+#include <winsock2.h>
+#include <Ws2tcpip.h>
+
+#include <iostream>
+
+namespace infinispan {
+namespace hotrod {
+namespace sys {
+
+// Part of a straw man IO layer
+
+
+
+namespace windows {
+
+class Socket: public infinispan::hotrod::sys::Socket {
+  public:
+    Socket();
+    virtual void connect();
+    virtual void close();
+    virtual size_t read(char *p, size_t n);
+    virtual void write(const char *p, size_t n);
+  private:
+    SOCKET fd;
+    static bool started;
+};
+
+namespace {
+// TODO: centralized hotrod exceptions with file name and line number
+void throwIOErr (const char *msg, int errnum) {
+    std::string m(msg);
+    if (errno != 0) {
+        char buf[200];
+        if (strerror_s(buf, 200, errnum) == 0) {
+            m += " ";
+            m += buf;
+        }
+        else {
+            m += " ";
+            m += strerror(errnum);
+        }
+    }
+    throw TransportException(m);
+}
+
+} /* namespace */
+
+bool Socket::started = false;
+
+Socket::Socket() : fd(INVALID_SOCKET) {
+    if (!started) {
+        /* Request WinSock 2.2 */
+        WORD wsa_ver = MAKEWORD(2, 2);
+        WSADATA unused;
+        int err = WSAStartup(wsa_ver, &unused);
+        if (err)
+            throwIOErr("windows WSAStartup failed", err);
+        started = true;
+    }
+}
+
+void Socket::connect() {
+    if (fd != -1) throwIOErr("reconnect attempt", 0);
+    SOCKET sock = socket(AF_INET, SOCK_STREAM, getprotobyname("tcp")->p_proto);
+    if (sock == INVALID_SOCKET) throwIOErr("connect", errno);
+
+    struct addrinfo *addr;
+    int ec = getaddrinfo("127.0.0.1", "11222", NULL, &addr);
+    if (ec) throwIOErr("getaddrinfo", errno);
+
+    if (::connect(sock, addr->ai_addr, (int)addr->ai_addrlen) != 0) {
+        int wsaerr =  WSAGetLastError();
+        freeaddrinfo(addr);
+        close();
+        throwIOErr("connect2", wsaerr);
+    }
+
+    freeaddrinfo(addr);
+    fd = sock;
+}
+
+void Socket::close() {
+    ::closesocket(fd);
+    fd = INVALID_SOCKET;
+}
+
+size_t Socket::read(char *p, size_t length) {
+    while(1) {
+        ssize_t n =  recv(fd, p, (int) length, 0);
+        if (n == SOCKET_ERROR)
+            throwIOErr("read", WSAGetLastError());
+        else if (n == 0)
+            return 0;
+        else
+            return n;
+    }
+}
+
+void Socket::write(const char *p, size_t length) {
+    ssize_t n = send(fd, p, (int) length, 0);
+    if (n == SOCKET_ERROR) throwIOErr ("write", WSAGetLastError());
+    if ((size_t) n != length) throwIOErr ("write error incomplete", 0);
+}
+
+} /* posix namespace */
+
+
+Socket* Socket::create() {
+    return new windows::Socket();
+}
+
+}}} /* namespace */
diff -Naur old/test/Simple.cpp cpp/test/Simple.cpp
--- old/test/Simple.cpp	1969-12-31 16:00:00.000000000 -0800
+++ cpp/test/Simple.cpp	2013-05-22 17:15:08.000000000 -0700
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010 Red Hat Inc. and/or its affiliates and other
+ * contributors as indicated by the @author tags. All rights reserved.
+ * See the copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+
+#include "infinispan/hotrod/RemoteCacheManager.h"
+#include "infinispan/hotrod/RemoteCache.h"
+#include "infinispan/hotrod/ScopedBuffer.h"
+
+#include <iostream>
+
+using namespace infinispan::hotrod;
+
+int main(int, char**) {
+    RemoteCacheManager cacheManager;
+    RemoteCache<std::string, std::string> cache = cacheManager.getCache<std::string, std::string>();
+
+    std::string k("abcdef");
+    std::string v("The rain in Spain");
+    std::string v2("falls mainly on the plain");
+
+    cache.put(k, v);
+    std::cout << "put and get test: " << cache.get(k) << " ";
+    cache.put(k, v2);
+    std::cout << cache.get(k) << std::endl;
+
+    try {
+        std::string badValue = cache.get(std::string("no such key in the cache"));
+        std::cout << "non-existent key failure, got " << badValue << "\n";
+    } catch(const HotRodClientException&) {
+        std::cout << "non-existent key test passed\n";
+    }
+
+    return 0;
+}
