face: Minor updates of TCP faces

Change-Id: I9a11fb4b2cd1aaaa670313cab0b08f097554e1fc
diff --git a/daemon/face/tcp-channel.cpp b/daemon/face/tcp-channel.cpp
index a983db6..246cdb0 100644
--- a/daemon/face/tcp-channel.cpp
+++ b/daemon/face/tcp-channel.cpp
@@ -154,9 +154,10 @@
 
     NFD_LOG_DEBUG("Connect to remote endpoint failed: "
                   << error.category().message(error.value()));
-    
-    onAcceptFailed("Connect to remote endpoint failed: " +
-                   error.category().message(error.value()));
+
+    if (static_cast<bool>(onAcceptFailed))
+      onAcceptFailed("Connect to remote endpoint failed: " +
+                     error.category().message(error.value()));
     return;
   }
 
diff --git a/daemon/face/tcp-factory.cpp b/daemon/face/tcp-factory.cpp
index 45b1a48..0994719 100644
--- a/daemon/face/tcp-factory.cpp
+++ b/daemon/face/tcp-factory.cpp
@@ -7,6 +7,9 @@
 #include "tcp-factory.hpp"
 #include "core/global-io.hpp"
 #include "core/resolver.hpp"
+#include "core/logger.hpp"
+
+NFD_LOG_INIT("TcpFactory");
 
 namespace nfd {
 
@@ -24,23 +27,14 @@
 
   channel = make_shared<TcpChannel>(boost::ref(getGlobalIoService()), boost::cref(endpoint));
   m_channels[endpoint] = channel;
+  NFD_LOG_DEBUG("Channel [" << endpoint << "] created");
   return channel;
 }
 
 shared_ptr<TcpChannel>
 TcpFactory::createChannel(const std::string& localHost, const std::string& localPort)
 {
-  using boost::asio::ip::tcp;
-
-  tcp::resolver::query query(localHost, localPort);
-  tcp::resolver resolver(getGlobalIoService());
-
-  tcp::resolver::iterator end;
-  tcp::resolver::iterator i = resolver.resolve(query);
-  if (i == end)
-    return shared_ptr<TcpChannel>();
-
-  return createChannel(*i);
+  return createChannel(TcpResolver::syncResolve(localHost, localPort));
 }
 
 shared_ptr<TcpChannel>
@@ -64,13 +58,12 @@
   else if (uri.getScheme() == "tcp6")
     addressSelector = resolver::Ipv6Address();
 
-  using boost::asio::ip::tcp;
-  Resolver<tcp>::asyncResolve(uri.getDomain(),
-                              uri.getPort().empty() ? m_defaultPort : uri.getPort(),
-                              bind(&TcpFactory::continueCreateFaceAfterResolve, this, _1,
-                                   onCreated, onConnectFailed),
-                              onConnectFailed,
-                              addressSelector);
+  TcpResolver::asyncResolve(uri.getDomain(),
+                            uri.getPort().empty() ? m_defaultPort : uri.getPort(),
+                            bind(&TcpFactory::continueCreateFaceAfterResolve, this, _1,
+                                 onCreated, onConnectFailed),
+                            onConnectFailed,
+                            addressSelector);
 }
 
 void
@@ -95,5 +88,4 @@
                   + boost::lexical_cast<std::string>(endpoint));
 }
 
-
 } // namespace nfd
diff --git a/daemon/face/tcp-factory.hpp b/daemon/face/tcp-factory.hpp
index 1886f24..6ba2e37 100644
--- a/daemon/face/tcp-factory.hpp
+++ b/daemon/face/tcp-factory.hpp
@@ -54,7 +54,7 @@
    *
    * Note that this call will **BLOCK** until resolution is done or failed.
    *
-   * \throws TcpFactory::Error
+   * \throws TcpFactory::Error or std::runtime_error
    */
   shared_ptr<TcpChannel>
   createChannel(const std::string& localHost, const std::string& localPort);