transport: use /run/nfd.sock on Linux

refs #5039

Change-Id: Ia81115676427db1ebdf4d72d9aadf2e34e2f0ae6
diff --git a/client.conf.sample b/client.conf.sample
index 9eae16e..b1debc8 100644
--- a/client.conf.sample
+++ b/client.conf.sample
@@ -6,7 +6,10 @@
 ;   tcp://192.0.2.1
 ;   tcp4://example.com:6363
 ;
-transport=unix:///var/run/nfd.sock
+; The default value of this field is platform-dependent, being unix:///run/nfd.sock on Linux and
+; unix:///var/run/nfd.sock on other platforms.
+;
+;transport=unix:///var/run/nfd.sock
 
 ; "pib" determines which Public Info Base (PIB) should used by default in applications.
 ; If "pib" is not specified, a platform-dependent default will be used.
diff --git a/docs/manpages/ndn-client.conf.rst b/docs/manpages/ndn-client.conf.rst
index 62f42ca..5908972 100644
--- a/docs/manpages/ndn-client.conf.rst
+++ b/docs/manpages/ndn-client.conf.rst
@@ -19,10 +19,11 @@
 ---
 
 transport
-  FaceUri for default connection toward local NDN forwarder.  Only ``unix`` and ``tcp4`` FaceUris
-  can be specified here.
+  FaceUri for default connection toward local NDN forwarder.  Only ``unix``, ``tcp``, ``tcp4``, and
+  ``tcp6`` FaceUris can be specified here.
 
-  By default, ``unix:///var/run/nfd.sock`` is used.
+  By default, ``unix:///run/nfd.sock`` is used on Linux and ``unix:///var/run/nfd.sock`` is used on
+  other platforms.
 
   .. note::
     This value can be overridden using the ``NDN_CLIENT_TRANSPORT`` environment variable.
diff --git a/ndn-cxx/face.cpp b/ndn-cxx/face.cpp
index 8b20ae3..3843bc6 100644
--- a/ndn-cxx/face.cpp
+++ b/ndn-cxx/face.cpp
@@ -100,9 +100,6 @@
 shared_ptr<Transport>
 Face::makeDefaultTransport()
 {
-  // transport=unix:///var/run/nfd.sock
-  // transport=tcp://localhost:6363
-
   std::string transportUri;
 
   const char* transportEnviron = getenv("NDN_CLIENT_TRANSPORT");
diff --git a/ndn-cxx/transport/unix-transport.cpp b/ndn-cxx/transport/unix-transport.cpp
index 6e909a2..f1f1526 100644
--- a/ndn-cxx/transport/unix-transport.cpp
+++ b/ndn-cxx/transport/unix-transport.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2013-2019 Regents of the University of California.
+ * Copyright (c) 2013-2020 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -42,7 +42,11 @@
 UnixTransport::getSocketNameFromUri(const std::string& uriString)
 {
   // Assume the default nfd.sock location.
+#ifdef __linux__
+  std::string path = "/run/nfd.sock";
+#else
   std::string path = "/var/run/nfd.sock";
+#endif // __linux__
 
   if (uriString.empty()) {
     return path;
diff --git a/tests/unit/transport/unix-transport.t.cpp b/tests/unit/transport/unix-transport.t.cpp
index 41c46b9..5711859 100644
--- a/tests/unit/transport/unix-transport.t.cpp
+++ b/tests/unit/transport/unix-transport.t.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2013-2018 Regents of the University of California.
+ * Copyright (c) 2013-2020 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -32,27 +32,19 @@
 
 using ndn::Transport;
 
-BOOST_AUTO_TEST_CASE(GetDefaultSocketNameOk)
+BOOST_AUTO_TEST_CASE(GetSocketNameFromUri)
 {
   BOOST_CHECK_EQUAL(UnixTransport::getSocketNameFromUri("unix:///tmp/test/nfd.sock"), "/tmp/test/nfd.sock");
-}
-
-BOOST_AUTO_TEST_CASE(GetDefaultSocketNameOkOmittedSocketOmittedProtocol)
-{
+#ifdef __linux__
+  BOOST_CHECK_EQUAL(UnixTransport::getSocketNameFromUri(""), "/run/nfd.sock");
+#else
   BOOST_CHECK_EQUAL(UnixTransport::getSocketNameFromUri(""), "/var/run/nfd.sock");
-}
-
-BOOST_AUTO_TEST_CASE(GetDefaultSocketNameBadWrongTransport)
-{
+#endif // __linux__
   BOOST_CHECK_EXCEPTION(UnixTransport::getSocketNameFromUri("tcp://"),
                         Transport::Error,
                         [] (const Transport::Error& error) {
                           return error.what() == "Cannot create UnixTransport from \"tcp\" URI"s;
                         });
-}
-
-BOOST_AUTO_TEST_CASE(GetDefaultSocketNameBadMalformedUri)
-{
   BOOST_CHECK_EXCEPTION(UnixTransport::getSocketNameFromUri("unix"),
                         Transport::Error,
                         [] (const Transport::Error& error) {