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?