diff --git a/js/WebSocketTransport.js b/js/WebSocketTransport.js
index e2a78a6..fc17e85 100644
--- a/js/WebSocketTransport.js
+++ b/js/WebSocketTransport.js
@@ -231,7 +231,7 @@
 										if (LOG > 3) console.log("Fetch key according to keylocator");
 										var nextClosure = new KeyFetchClosure(co, currentClosure, keylocator.keyName, sigHex, wit);
 										var interest = new Interest(keylocator.keyName.contentName.getPrefix(4));
-										interest.interestLifetime = 4.0;
+										interest.interestLifetime = 4000;  // milliseconds
 										self.expressInterest(ndn, interest, nextClosure);
 									}
 								}
diff --git a/js/XpcomTransport.js b/js/XpcomTransport.js
index 42273f2..57f9dd9 100644
--- a/js/XpcomTransport.js
+++ b/js/XpcomTransport.js
@@ -9,61 +9,183 @@
 // Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
 // Components.utils.import("resource://gre/modules/NetUtil.jsm");
 
-var XpcomTransport = function XpcomTransport() { 
+var XpcomTransport = function XpcomTransport() {
+    this.ndn = null;
+    this.socket = null; // nsISocketTransport
+    this.outStream = null;
+    this.connectedHost = null;
+    this.connectedPort = null;
+    
     this.defaultGetHostAndPort = NDN.makeShuffledGetHostAndPort
         (["A.hub.ndn.ucla.edu", "B.hub.ndn.ucla.edu", "C.hub.ndn.ucla.edu", "D.hub.ndn.ucla.edu", 
           "E.hub.ndn.ucla.edu", "F.hub.ndn.ucla.edu", "G.hub.ndn.ucla.edu", "H.hub.ndn.ucla.edu"],
          9695);
 };
 
-XpcomTransport.prototype.expressInterest = function(ndn, interest, closure) {
-    var binaryInterest = encodeToBinaryInterest(interest);
+/*
+ * Connect to the host and port in ndn.  This replaces a previous connection.
+ * Listen on the port to read an entire binary XML encoded response and call
+ *    listener.onReceivedData(data) where data is Uint8Array.
+ */
+XpcomTransport.prototype.connect = function(ndn, listener) {
+    if (this.socket != null) {
+        try {
+            this.socket.close(0);
+        } catch (ex) {
+			console.log("XpcomTransport socket.close exception: " + ex);
+		}
+        this.socket = null;
+    }
+    this.ndn = ndn;
+
+	var transportService = Components.classes["@mozilla.org/network/socket-transport-service;1"].getService
+        (Components.interfaces.nsISocketTransportService);
+	var pump = Components.classes["@mozilla.org/network/input-stream-pump;1"].createInstance
+        (Components.interfaces.nsIInputStreamPump);
+	this.socket = transportService.createTransport(null, 0, ndn.host, ndn.port, null);
+    this.connectedHost = ndn.host;
+    this.connectedPort = ndn.port;
+    this.outStream = this.socket.openOutputStream(1, 0, 0);
+
+    var inStream = this.socket.openInputStream(0, 0, 0);
+	var dataListener = {
+		dataParts: [],
+        structureDecoder: new BinaryXMLStructureDecoder(),
+		
+		onStartRequest: function (request, context) {
+		},
+		onStopRequest: function (request, context, status) {
+		},
+		onDataAvailable: function (request, context, _inputStream, offset, count) {
+			try {
+				// Use readInputStreamToString to handle binary data.
+                // TODO: Can we go directly from the stream to Uint8Array?
+				var rawData = DataUtils.toNumbersFromString
+                    (NetUtil.readInputStreamToString(inStream, count));
+				
+                // Process multiple objects in this packet.
+                while(true) {
+                    // Scan the input to check if a whole ccnb object has been read.
+                    this.structureDecoder.seek(0);
+                    if (this.structureDecoder.findElementEnd(rawData)) {
+                        // Got the remainder of an object.  Report to the caller.
+                        this.dataParts.push(rawData.subarray(0, this.structureDecoder.offset));
+                        listener.onReceivedData(DataUtils.concatArrays(this.dataParts));
+                    
+                        // Need to read a new object.
+                        rawData = rawData.subarray(this.structureDecoder.offset, rawData.length);
+                        this.dataParts = [];
+                        this.structureDecoder = new BinaryXMLStructureDecoder();
+                        if (rawData.length == 0)
+                            // No more data in the packet.
+                            return;
+                        
+                        // else loop back to decode.
+                    }
+                    else {
+                        // Save for a later call to concatArrays so that we only copy data once.
+                        this.dataParts.push(rawData);
+                        return;
+                    }
+                }
+			} catch (ex) {
+				console.log("XpcomTransport.onDataAvailable exception: " + ex);
+			}
+		}
+    };
+	
+	pump.init(inStream, -1, -1, 0, 0, true);
+    pump.asyncRead(dataListener, null);
+};
+
+/*
+ * Send the data over the connection created by connect.
+ */
+XpcomTransport.prototype.send = function(/* Uint8Array */ data) {
+    if (this.socket == null) {
+        console.log("XpcomTransport connection is not established.");
+        return;
+    }
     
-    var dataListener = {
+    var rawDataString = DataUtils.toString(data);
+	this.outStream.write(rawDataString, rawDataString.length);
+	this.outStream.flush();
+};
+
+XpcomTransport.prototype.expressInterest = function(ndn, interest, closure) {
+    var thisXpcomTransport = this;
+    
+    if (this.socket == null || this.connectedHost != ndn.host || this.connectedPort != ndn.port) {
+      var dataListener = {
 		onReceivedData : function(data) {
 			if (data == null || data == undefined || data.length == 0)
-				dump("NDN.expressInterest: received empty data from socket.\n");
+				console.log("XpcomTransport: received empty data from socket.");
 			else {
                 var decoder = new BinaryXMLDecoder(data);
                 if (decoder.peekStartElement(CCNProtocolDTags.Interest)) {
-                    // TODO: handle interest
-                    if (closure.upcall(Closure.UPCALL_INTEREST, null) == Closure.RESULT_OK)
-                        // success
-                        return true;
+                    // TODO: handle interest properly.  For now, assume the only use in getting
+                    //   an interest is knowing that the host is alive from NDN.ccndIdFetcher.
+					var pitEntry = NDN.getEntryForExpressedInterest(NDN.ccndIdFetcher);
+					if (pitEntry != null) {
+						// Remove PIT entry from NDN.PITTable.
+						var index = NDN.PITTable.indexOf(pitEntry);
+						if (index >= 0)
+							NDN.PITTable.splice(index, 1);
+                        
+                        pitEntry.closure.upcall(Closure.UPCALL_INTEREST, null);
+                    }
                 }
                 else if (decoder.peekStartElement(CCNProtocolDTags.ContentObject)) {
                     var co = new ContentObject();
                     co.from_ccnb(decoder);
                    					
-                    // TODO: verify the content object and set kind to UPCALL_CONTENT.
-                    var result = closure.upcall(Closure.UPCALL_CONTENT_UNVERIFIED,
-                               new UpcallInfo(ndn, interest, 0, co));
-                    if (result == Closure.RESULT_OK)
-                        // success
-                        return true;
-                    else if (result == Closure.RESULT_ERR)
-                        dump("NDN.expressInterest: upcall returned RESULT_ERR.\n");
-                    else if (result == Closure.RESULT_REEXPRESS) {
-                        XpcomTransport.readAllFromSocket(ndn.host, ndn.port, binaryInterest, dataListener);
-                        return true;
+					var pitEntry = NDN.getEntryForExpressedInterest(co.name);
+					if (pitEntry != null) {
+						// Remove PIT entry from NDN.PITTable.
+                        // TODO: This needs to be a single thread-safe transaction.
+						var index = NDN.PITTable.indexOf(pitEntry);
+						if (index >= 0)
+							NDN.PITTable.splice(index, 1);
                     }
-                    else if (result == Closure.RESULT_VERIFY) {
-                        // TODO: force verification of content.
-                    }
-                    else if (result == Closure.RESULT_FETCHKEY) {
-                        // TODO: get the key in the key locator and re-call the interest
-                        //   with the key available in the local storage.
+   					if (pitEntry != null) {
+						var currentClosure = pitEntry.closure;
+                        
+                        // TODO: verify the content object and set kind to UPCALL_CONTENT.
+                        var result = currentClosure.upcall(Closure.UPCALL_CONTENT_UNVERIFIED,
+                                    new UpcallInfo(thisXpcomTransport.ndn, null, 0, co));
+                        if (result == Closure.RESULT_OK) {
+                            // success
+                        }
+                        else if (result == Closure.RESULT_ERR)
+                            console.log("XpcomTransport: upcall returned RESULT_ERR.");
+                        else if (result == Closure.RESULT_REEXPRESS) {
+                            // TODO: Handl re-express interest.
+                        }
+                        else if (result == Closure.RESULT_VERIFY) {
+                            // TODO: force verification of content.
+                        }
+                        else if (result == Closure.RESULT_FETCHKEY) {
+                            // TODO: get the key in the key locator and re-call the interest
+                            //   with the key available in the local storage.
+                        }
                     }
                 }
                 else
                     console.log('Incoming packet is not Interest or ContentObject. Discard now.');
 			}
-            
-            return false;
 		}
-	}    
+	  }
+      
+      this.connect(ndn, dataListener);
+    }
     
-	XpcomTransport.readAllFromSocket(ndn.host, ndn.port, binaryInterest, dataListener);
+    var binaryInterest = encodeToBinaryInterest(interest);
+    
+                        // TODO: This needs to be a single thread-safe transaction.
+	var pitEntry = new PITEntry(interest, closure);
+	NDN.PITTable.push(pitEntry);
+
+    this.send(binaryInterest);
 };
 
 /** Send outputData (Uint8Array) to host:port, read the entire response and call 
@@ -71,16 +193,16 @@
  *    false if need to keep reading.
  *  Code derived from http://stackoverflow.com/questions/7816386/why-nsiscriptableinputstream-is-not-working .
  */
+ /*
 XpcomTransport.readAllFromSocket = function(host, port, outputData, listener) {
 	var transportService = Components.classes["@mozilla.org/network/socket-transport-service;1"].getService
         (Components.interfaces.nsISocketTransportService);
-	var pump = Components.classes["@mozilla.org/network/input-stream-pump;1"].createInstance
-        (Components.interfaces.nsIInputStreamPump);
 	var transport = transportService.createTransport(null, 0, host, port, null);
 	var outStream = transport.openOutputStream(1, 0, 0);
     var rawDataString = DataUtils.toString(outputData);
 	outStream.write(rawDataString, rawDataString.length);
 	outStream.flush();
+    outStream.close();
 	var inStream = transport.openInputStream(0, 0, 0);
 	var dataListener = {
 		dataParts: [],
@@ -91,7 +213,6 @@
 		},
 		onStopRequest: function (request, context, status) {
 			inStream.close();
-			outStream.close();
 		},
 		onDataAvailable: function (request, context, _inputStream, offset, count) {
             if (this.dataIsConsumed)
@@ -134,12 +255,15 @@
                     }
                 }
 			} catch (ex) {
-				dump("readAllFromSocket.onDataAvailable exception: " + ex + "\n");
+				console.log("readAllFromSocket.onDataAvailable exception: " + ex);
 			}
 		}
     };
 	
+	var pump = Components.classes["@mozilla.org/network/input-stream-pump;1"].createInstance
+        (Components.interfaces.nsIInputStreamPump);
 	pump.init(inStream, -1, -1, 0, 0, true);
     pump.asyncRead(dataListener, null);
 }
+*/
 
diff --git a/js/ndnProtocol.xpi b/js/ndnProtocol.xpi
index 9f9690c..2b880b0 100644
--- a/js/ndnProtocol.xpi
+++ b/js/ndnProtocol.xpi
Binary files differ
diff --git a/js/ndnProtocol/components/ndnProtocolService.js b/js/ndnProtocol/components/ndnProtocolService.js
index ca8cc1b..a6f7f01 100644
--- a/js/ndnProtocol/components/ndnProtocolService.js
+++ b/js/ndnProtocol/components/ndnProtocolService.js
@@ -29,13 +29,39 @@
 
     newURI: function(aSpec, aOriginCharset, aBaseURI)
     {
-        // We have to trim now because nsIURI converts spaces to %20 and we can't trim in newChannel.
-        var spec = aSpec.trim();
-        var preSearch = spec.split('?', 1)[0];
-        var searchAndHash = spec.substr(preSearch.length).trim();
-
         var uri = Cc["@mozilla.org/network/simple-uri;1"].createInstance(Ci.nsIURI);
-        uri.spec = preSearch.trim() + searchAndHash;
+
+        // We have to trim now because nsIURI converts spaces to %20 and we can't trim in newChannel.
+        var uriParts = NdnProtocolInfo.splitUri(aSpec);
+        if (aBaseURI == null || uriParts.name.length < 1 || uriParts.name[0] == '/')
+            // Just reconstruct the trimmed URI.
+            uri.spec = "ndn:" + uriParts.name + uriParts.search + uriParts.hash;
+        else {
+            // Make a URI relative to the base name up to the file name component.
+            var baseUriParts = NdnProtocolInfo.splitUri(aBaseURI.spec);
+            var baseName = new Name(baseUriParts.name);
+            var iFileName = baseName.indexOfFileName();
+            
+            var relativeName = uriParts.name;
+            // Handle ../
+            while (true) {
+                if (relativeName.substr(0, 2) == "./")
+                    relativeName = relativeName.substr(2);
+                else if (relativeName.substr(0, 3) == "../") {
+                    relativeName = relativeName.substr(3);
+                    if (iFileName > 0)
+                        --iFileName;
+                }
+                else
+                    break;
+            }
+            
+            var prefixUri = "/";
+            if (iFileName > 0)
+                prefixUri = new Name(baseName.components.slice(0, iFileName)).to_uri() + "/";
+            uri.spec = "ndn:" + prefixUri + relativeName + uriParts.search + uriParts.hash;
+        }
+        
         return uri;
     },
 
@@ -44,21 +70,12 @@
         var thisNdnProtocol = this;
         
         try {            
-            // Decode manually since nsIURI doesn't have selectors for hash, etc.
-            var spec = aURI.spec.trim();
-            var preHash = spec.split('#', 1)[0];
-            var hash = spec.substr(preHash.length).trim();
-            var preSearch = preHash.split('?', 1)[0];
-            var search = preHash.substr(preSearch.length).trim();
-            // Set nameString to the preSearch without the protocol.
-            var nameString = preSearch.trim();
-            if (nameString.indexOf(':') >= 0)
-                nameString = nameString.substr(nameString.indexOf(':') + 1).trim();
+            var uriParts = NdnProtocolInfo.splitUri(aURI.spec);
     
             var template = new Interest(new Name([]));
             // Use the same default as NDN.expressInterest.
             template.interestLifetime = 4000; // milliseconds
-            var searchWithoutNdn = extractNdnSearch(search, template);
+            var searchWithoutNdn = extractNdnSearch(uriParts.search, template);
             
             var segmentTemplate = new Interest(new Name([]));
             // Only use the interest selectors which make sense for fetching further segments.
@@ -67,14 +84,14 @@
             segmentTemplate.interestLifetime = template.interestLifetime;
     
             var requestContent = function(contentListener) {                
-                var name = new Name(nameString);
+                var name = new Name(uriParts.name);
                 // TODO: Strip off an ending implicit digest before checking the last component?
                 var uriEndsWithSegmentNumber = endsWithSegmentNumber(name);
                 
                 // Use the same NDN object each time.
                 thisNdnProtocol.ndn.expressInterest(name, 
                     new ContentClosure(thisNdnProtocol.ndn, contentListener, uriEndsWithSegmentNumber, 
-                            aURI.originCharset, searchWithoutNdn + hash, segmentTemplate),
+                            aURI.originCharset, searchWithoutNdn + uriParts.hash, segmentTemplate),
                     template);
             };
 
@@ -136,7 +153,7 @@
     }
     
     // Now that we're connected, report the host and port.
-    setConnectedNdnHub(this.ndn.host, this.ndn.port);
+    NdnProtocolInfo.setConnectedNdnHub(this.ndn.host, this.ndn.port);
 
     // If !this.uriEndsWithSegmentNumber, we use the segmentNumber to load multiple segments.
     var segmentNumber = null;
diff --git a/js/ndnProtocol/content/ndnToolbar.js b/js/ndnProtocol/content/ndnToolbar.js
index 20518a3..0c34fb2 100644
--- a/js/ndnProtocol/content/ndnToolbar.js
+++ b/js/ndnProtocol/content/ndnToolbar.js
@@ -8,17 +8,8 @@
   }
 
   // Parse the same as in ndnProtocolService newChannel.
-  var spec = window._content.document.location.href.trim();
-  var preHash = spec.split('#', 1)[0];
-  var hash = spec.substr(preHash.length).trim();
-  var preSearch = preHash.split('?', 1)[0];
-  var search = preHash.substr(preSearch.length).trim();
-  // Set nameString to the preSearch without the protocol.
-  var nameString = preSearch.trim();
-  if (nameString.indexOf(':') >= 0)
-    nameString = nameString.substr(nameString.indexOf(':') + 1).trim();
-
-  var name = new Name(nameString);
+  var uriParts = NdnProtocolInfo.splitUri(window._content.document.location.href);
+  var name = new Name(uriParts.name);
   var indexOfVersion = getIndexOfVersion(name);
   if (indexOfVersion < 0) {
     alert("The ndn address does not have a version");
@@ -26,9 +17,10 @@
   }
 
   var nameWithoutVersion = new Name(name.components.slice(0, indexOfVersion));
-  var searchWithChildSelector = (search == "" ? "?" : search + "&") + "ndn.ChildSelector=1";
+  var searchWithChildSelector = 
+      (uriParts.search == "" ? "?" : uriParts.search + "&") + "ndn.ChildSelector=1";
     
-  var uri = "ndn:" + nameWithoutVersion.to_uri() + searchWithChildSelector + hash;
+  var uri = "ndn:" + nameWithoutVersion.to_uri() + searchWithChildSelector + uriParts.hash;
   window._content.document.location = uri;
 } 
 
@@ -51,4 +43,4 @@
    document.getElementById("ndnHubLabel").setAttribute("value", "Hub: " + host + ":" + port);
 }
 
-window.addEventListener("load", function() { addNdnHubChangedListener(onNdnHubChanged); }, false);
+window.addEventListener("load", function() { NdnProtocolInfo.addNdnHubChangedListener(onNdnHubChanged); }, false);
diff --git a/js/ndnProtocol/modules/NdnProtocolInfo.jsm b/js/ndnProtocol/modules/NdnProtocolInfo.jsm
index a2fb10d..3a5fc79 100644
--- a/js/ndnProtocol/modules/NdnProtocolInfo.jsm
+++ b/js/ndnProtocol/modules/NdnProtocolInfo.jsm
@@ -3,7 +3,7 @@
  * See COPYING for copyright and distribution information.
  */
 
-var EXPORTED_SYMBOLS = ["addNdnHubChangedListener", "setConnectedNdnHub"];
+var EXPORTED_SYMBOLS = ["NdnProtocolInfo"];
 
 const Cc = Components.classes;
 const Ci = Components.interfaces;
@@ -11,20 +11,23 @@
 
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
 
-var ndnHubHost = null;
-var ndnHubPort = null;
-var ndnHubChangedListenerList = [];
+var NdnProtocolInfo = function NdnProtocolInfo(){
+};
+
+NdnProtocolInfo.ndnHubHost = null;
+NdnProtocolInfo.ndnHubPort = null;
+NdnProtocolInfo.ndnHubChangedListenerList = [];
 
 /*
  * When the NDN hub host or port is changed, the system calls listener(host, port).
  * If the current host and port are not null, call listener with the values to initialize.
  */
-function addNdnHubChangedListener(listener) {
-    ndnHubChangedListenerList.push(listener);
+NdnProtocolInfo.addNdnHubChangedListener = function(listener) {
+    NdnProtocolInfo.ndnHubChangedListenerList.push(listener);
     
-    if (ndnHubHost != null && ndnHubPort != null) {
+    if (NdnProtocolInfo.ndnHubHost != null && NdnProtocolInfo.ndnHubPort != null) {
         try {
-            listener(ndnHubHost, ndnHubPort);
+            listener(NdnProtocolInfo.ndnHubHost, NdnProtocolInfo.ndnHubPort);
         }
         catch (ex) {
             // Ignore error from the listener.
@@ -36,19 +39,47 @@
  * If host and port are different than ndnHubHost or ndnHubPort, set them and call each
  * listener in ndnHubChangedListenerList.
  */
-function setConnectedNdnHub(host, port) {
-    if (host == ndnHubHost && port == ndnHubPort)
+NdnProtocolInfo.setConnectedNdnHub = function(host, port) {
+    if (host == NdnProtocolInfo.ndnHubHost && port == NdnProtocolInfo.ndnHubPort)
         // No change.
         return;
     
-    ndnHubHost = host;
-    ndnHubPort = port;
-    for (var i = 0; i < ndnHubChangedListenerList.length; ++i) {
+    NdnProtocolInfo.ndnHubHost = host;
+    NdnProtocolInfo.ndnHubPort = port;
+    for (var i = 0; i < NdnProtocolInfo.ndnHubChangedListenerList.length; ++i) {
         try {
-            ndnHubChangedListenerList[i](host, port);
+            NdnProtocolInfo.ndnHubChangedListenerList[i](host, port);
         }
         catch (ex) {
             // Ignore error from the listener.
         }
     }
-}
\ No newline at end of file
+}
+
+/*
+ * Split the URI spec and return an object with protocol (including ':'), name, 
+ *   search (including '?') and hash value (including '#').  
+ * All result strings are trimmed.  This does not unescape the name.
+ * The name may include a host and port.  
+ */
+NdnProtocolInfo.splitUri = function(spec) {
+    spec = spec.trim();
+    var result = {};
+    var preHash = spec.split('#', 1)[0];
+    result.hash = spec.substr(preHash.length).trim();
+    var preSearch = preHash.split('?', 1)[0];
+    result.search = preHash.substr(preSearch.length).trim();
+    
+    preSearch = preSearch.trim();
+    var colonIndex = preSearch.indexOf(':');
+    if (colonIndex >= 0) {
+        result.protocol = preSearch.substr(0, colonIndex + 1).trim();
+        result.name = preSearch.substr(colonIndex + 1).trim();    
+    }
+    else {
+        result.protocol = "";
+        result.name = preSearch;
+    }
+    
+    return result;
+}
diff --git a/js/ndnProtocol/modules/ndn-js.jsm b/js/ndnProtocol/modules/ndn-js.jsm
index ab41f5e..32705a3 100644
--- a/js/ndnProtocol/modules/ndn-js.jsm
+++ b/js/ndnProtocol/modules/ndn-js.jsm
@@ -317,61 +317,183 @@
 // Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
 // Components.utils.import("resource://gre/modules/NetUtil.jsm");
 
-var XpcomTransport = function XpcomTransport() { 
+var XpcomTransport = function XpcomTransport() {
+    this.ndn = null;
+    this.socket = null; // nsISocketTransport
+    this.outStream = null;
+    this.connectedHost = null;
+    this.connectedPort = null;
+    
     this.defaultGetHostAndPort = NDN.makeShuffledGetHostAndPort
         (["A.hub.ndn.ucla.edu", "B.hub.ndn.ucla.edu", "C.hub.ndn.ucla.edu", "D.hub.ndn.ucla.edu", 
           "E.hub.ndn.ucla.edu", "F.hub.ndn.ucla.edu", "G.hub.ndn.ucla.edu", "H.hub.ndn.ucla.edu"],
          9695);
 };
 
-XpcomTransport.prototype.expressInterest = function(ndn, interest, closure) {
-    var binaryInterest = encodeToBinaryInterest(interest);
+/*
+ * Connect to the host and port in ndn.  This replaces a previous connection.
+ * Listen on the port to read an entire binary XML encoded response and call
+ *    listener.onReceivedData(data) where data is Uint8Array.
+ */
+XpcomTransport.prototype.connect = function(ndn, listener) {
+    if (this.socket != null) {
+        try {
+            this.socket.close(0);
+        } catch (ex) {
+			console.log("XpcomTransport socket.close exception: " + ex);
+		}
+        this.socket = null;
+    }
+    this.ndn = ndn;
+
+	var transportService = Components.classes["@mozilla.org/network/socket-transport-service;1"].getService
+        (Components.interfaces.nsISocketTransportService);
+	var pump = Components.classes["@mozilla.org/network/input-stream-pump;1"].createInstance
+        (Components.interfaces.nsIInputStreamPump);
+	this.socket = transportService.createTransport(null, 0, ndn.host, ndn.port, null);
+    this.connectedHost = ndn.host;
+    this.connectedPort = ndn.port;
+    this.outStream = this.socket.openOutputStream(1, 0, 0);
+
+    var inStream = this.socket.openInputStream(0, 0, 0);
+	var dataListener = {
+		dataParts: [],
+        structureDecoder: new BinaryXMLStructureDecoder(),
+		
+		onStartRequest: function (request, context) {
+		},
+		onStopRequest: function (request, context, status) {
+		},
+		onDataAvailable: function (request, context, _inputStream, offset, count) {
+			try {
+				// Use readInputStreamToString to handle binary data.
+                // TODO: Can we go directly from the stream to Uint8Array?
+				var rawData = DataUtils.toNumbersFromString
+                    (NetUtil.readInputStreamToString(inStream, count));
+				
+                // Process multiple objects in this packet.
+                while(true) {
+                    // Scan the input to check if a whole ccnb object has been read.
+                    this.structureDecoder.seek(0);
+                    if (this.structureDecoder.findElementEnd(rawData)) {
+                        // Got the remainder of an object.  Report to the caller.
+                        this.dataParts.push(rawData.subarray(0, this.structureDecoder.offset));
+                        listener.onReceivedData(DataUtils.concatArrays(this.dataParts));
+                    
+                        // Need to read a new object.
+                        rawData = rawData.subarray(this.structureDecoder.offset, rawData.length);
+                        this.dataParts = [];
+                        this.structureDecoder = new BinaryXMLStructureDecoder();
+                        if (rawData.length == 0)
+                            // No more data in the packet.
+                            return;
+                        
+                        // else loop back to decode.
+                    }
+                    else {
+                        // Save for a later call to concatArrays so that we only copy data once.
+                        this.dataParts.push(rawData);
+                        return;
+                    }
+                }
+			} catch (ex) {
+				console.log("XpcomTransport.onDataAvailable exception: " + ex);
+			}
+		}
+    };
+	
+	pump.init(inStream, -1, -1, 0, 0, true);
+    pump.asyncRead(dataListener, null);
+};
+
+/*
+ * Send the data over the connection created by connect.
+ */
+XpcomTransport.prototype.send = function(/* Uint8Array */ data) {
+    if (this.socket == null) {
+        console.log("XpcomTransport connection is not established.");
+        return;
+    }
     
-    var dataListener = {
+    var rawDataString = DataUtils.toString(data);
+	this.outStream.write(rawDataString, rawDataString.length);
+	this.outStream.flush();
+};
+
+XpcomTransport.prototype.expressInterest = function(ndn, interest, closure) {
+    var thisXpcomTransport = this;
+    
+    if (this.socket == null || this.connectedHost != ndn.host || this.connectedPort != ndn.port) {
+      var dataListener = {
 		onReceivedData : function(data) {
 			if (data == null || data == undefined || data.length == 0)
-				dump("NDN.expressInterest: received empty data from socket.\n");
+				console.log("XpcomTransport: received empty data from socket.");
 			else {
                 var decoder = new BinaryXMLDecoder(data);
                 if (decoder.peekStartElement(CCNProtocolDTags.Interest)) {
-                    // TODO: handle interest
-                    if (closure.upcall(Closure.UPCALL_INTEREST, null) == Closure.RESULT_OK)
-                        // success
-                        return true;
+                    // TODO: handle interest properly.  For now, assume the only use in getting
+                    //   an interest is knowing that the host is alive from NDN.ccndIdFetcher.
+					var pitEntry = NDN.getEntryForExpressedInterest(NDN.ccndIdFetcher);
+					if (pitEntry != null) {
+						// Remove PIT entry from NDN.PITTable.
+						var index = NDN.PITTable.indexOf(pitEntry);
+						if (index >= 0)
+							NDN.PITTable.splice(index, 1);
+                        
+                        pitEntry.closure.upcall(Closure.UPCALL_INTEREST, null);
+                    }
                 }
                 else if (decoder.peekStartElement(CCNProtocolDTags.ContentObject)) {
                     var co = new ContentObject();
                     co.from_ccnb(decoder);
                    					
-                    // TODO: verify the content object and set kind to UPCALL_CONTENT.
-                    var result = closure.upcall(Closure.UPCALL_CONTENT_UNVERIFIED,
-                               new UpcallInfo(ndn, interest, 0, co));
-                    if (result == Closure.RESULT_OK)
-                        // success
-                        return true;
-                    else if (result == Closure.RESULT_ERR)
-                        dump("NDN.expressInterest: upcall returned RESULT_ERR.\n");
-                    else if (result == Closure.RESULT_REEXPRESS) {
-                        XpcomTransport.readAllFromSocket(ndn.host, ndn.port, binaryInterest, dataListener);
-                        return true;
+					var pitEntry = NDN.getEntryForExpressedInterest(co.name);
+					if (pitEntry != null) {
+						// Remove PIT entry from NDN.PITTable.
+                        // TODO: This needs to be a single thread-safe transaction.
+						var index = NDN.PITTable.indexOf(pitEntry);
+						if (index >= 0)
+							NDN.PITTable.splice(index, 1);
                     }
-                    else if (result == Closure.RESULT_VERIFY) {
-                        // TODO: force verification of content.
-                    }
-                    else if (result == Closure.RESULT_FETCHKEY) {
-                        // TODO: get the key in the key locator and re-call the interest
-                        //   with the key available in the local storage.
+   					if (pitEntry != null) {
+						var currentClosure = pitEntry.closure;
+                        
+                        // TODO: verify the content object and set kind to UPCALL_CONTENT.
+                        var result = currentClosure.upcall(Closure.UPCALL_CONTENT_UNVERIFIED,
+                                    new UpcallInfo(thisXpcomTransport.ndn, null, 0, co));
+                        if (result == Closure.RESULT_OK) {
+                            // success
+                        }
+                        else if (result == Closure.RESULT_ERR)
+                            console.log("XpcomTransport: upcall returned RESULT_ERR.");
+                        else if (result == Closure.RESULT_REEXPRESS) {
+                            // TODO: Handl re-express interest.
+                        }
+                        else if (result == Closure.RESULT_VERIFY) {
+                            // TODO: force verification of content.
+                        }
+                        else if (result == Closure.RESULT_FETCHKEY) {
+                            // TODO: get the key in the key locator and re-call the interest
+                            //   with the key available in the local storage.
+                        }
                     }
                 }
                 else
                     console.log('Incoming packet is not Interest or ContentObject. Discard now.');
 			}
-            
-            return false;
 		}
-	}    
+	  }
+      
+      this.connect(ndn, dataListener);
+    }
     
-	XpcomTransport.readAllFromSocket(ndn.host, ndn.port, binaryInterest, dataListener);
+    var binaryInterest = encodeToBinaryInterest(interest);
+    
+                        // TODO: This needs to be a single thread-safe transaction.
+	var pitEntry = new PITEntry(interest, closure);
+	NDN.PITTable.push(pitEntry);
+
+    this.send(binaryInterest);
 };
 
 /** Send outputData (Uint8Array) to host:port, read the entire response and call 
@@ -379,16 +501,16 @@
  *    false if need to keep reading.
  *  Code derived from http://stackoverflow.com/questions/7816386/why-nsiscriptableinputstream-is-not-working .
  */
+ /*
 XpcomTransport.readAllFromSocket = function(host, port, outputData, listener) {
 	var transportService = Components.classes["@mozilla.org/network/socket-transport-service;1"].getService
         (Components.interfaces.nsISocketTransportService);
-	var pump = Components.classes["@mozilla.org/network/input-stream-pump;1"].createInstance
-        (Components.interfaces.nsIInputStreamPump);
 	var transport = transportService.createTransport(null, 0, host, port, null);
 	var outStream = transport.openOutputStream(1, 0, 0);
     var rawDataString = DataUtils.toString(outputData);
 	outStream.write(rawDataString, rawDataString.length);
 	outStream.flush();
+    outStream.close();
 	var inStream = transport.openInputStream(0, 0, 0);
 	var dataListener = {
 		dataParts: [],
@@ -399,7 +521,6 @@
 		},
 		onStopRequest: function (request, context, status) {
 			inStream.close();
-			outStream.close();
 		},
 		onDataAvailable: function (request, context, _inputStream, offset, count) {
             if (this.dataIsConsumed)
@@ -442,14 +563,17 @@
                     }
                 }
 			} catch (ex) {
-				dump("readAllFromSocket.onDataAvailable exception: " + ex + "\n");
+				console.log("readAllFromSocket.onDataAvailable exception: " + ex);
 			}
 		}
     };
 	
+	var pump = Components.classes["@mozilla.org/network/input-stream-pump;1"].createInstance
+        (Components.interfaces.nsIInputStreamPump);
 	pump.init(inStream, -1, -1, 0, 0, true);
     pump.asyncRead(dataListener, null);
 }
+*/
 
 /*
  * This class defines MOME types based on the filename extension.
