Move the elementReader_ to a member of TcpTransport
diff --git a/ndn-cpp/transport/TcpTransport.cpp b/ndn-cpp/transport/TcpTransport.cpp
index 1db18bb..fe81b42 100644
--- a/ndn-cpp/transport/TcpTransport.cpp
+++ b/ndn-cpp/transport/TcpTransport.cpp
@@ -5,7 +5,6 @@
 
 #include <stdexcept>
 #include "../NDN.hpp"
-#include "../c/encoding/BinaryXMLElementReader.h"
 #include "TcpTransport.hpp"
 
 using namespace std;
@@ -17,6 +16,10 @@
   ndn_Error error;
   if (error = ndn_TcpTransport_connect(&transport_, (char *)ndn.getHost(), ndn.getPort()))
     throw std::runtime_error(ndn_getErrorString(error)); 
+
+  // TODO: This belongs in the socket listener.
+  // Automatically cast ndn_ to (struct ndn_ElementListener *)
+  ndn_BinaryXMLElementReader_init(&elementReader_, &ndn);
   
   // TODO: Properly indicate connected status.
   ndn_ = &ndn;
@@ -31,22 +34,14 @@
 
 void TcpTransport::tempReceive()
 {
-  if (!ndn_)
-    // TODO: Properly check if connected.
-    return;
-  
-  try {
-    ndn_BinaryXMLElementReader elementReader;
-    // Automatically cast ndn_ to (struct ndn_ElementListener *)
-    ndn_BinaryXMLElementReader_init(&elementReader, ndn_);
-    
+  try {   
     ndn_Error error;
     unsigned char buffer[8000];
     unsigned int nBytes;
     if (error = ndn_TcpTransport_receive(&transport_, buffer, sizeof(buffer), &nBytes))
       throw std::runtime_error(ndn_getErrorString(error));  
 
-    ndn_BinaryXMLElementReader_onReceivedData(&elementReader, buffer, nBytes);
+    ndn_BinaryXMLElementReader_onReceivedData(&elementReader_, buffer, nBytes);
   } catch (...) {
     // This function is called by the socket callback, so don't send an exception back to it.
     // TODO: Log the exception?
diff --git a/ndn-cpp/transport/TcpTransport.hpp b/ndn-cpp/transport/TcpTransport.hpp
index c4fa1c6..8be6a73 100644
--- a/ndn-cpp/transport/TcpTransport.hpp
+++ b/ndn-cpp/transport/TcpTransport.hpp
@@ -7,6 +7,7 @@
 #define	NDN_TCPTRANSPORT_HPP
 
 #include "../c/transport/TcpTransport.h"
+#include "../c/encoding/BinaryXMLElementReader.h"
 #include "Transport.hpp"
 
 namespace ndn {
@@ -28,6 +29,8 @@
 private:
   struct ndn_TcpTransport transport_;
   NDN *ndn_;
+  // TODO: This belongs in the socket listener.
+  ndn_BinaryXMLElementReader elementReader_;
 };
 
 }