THRIFT-2838 TNonblockingServer can bind to port 0 (i.e., get an OS-assigned port) but there is no way to get the port number
diff --git a/lib/cpp/src/thrift/server/TNonblockingServer.h b/lib/cpp/src/thrift/server/TNonblockingServer.h
index 3edc795..4f23487 100644
--- a/lib/cpp/src/thrift/server/TNonblockingServer.h
+++ b/lib/cpp/src/thrift/server/TNonblockingServer.h
@@ -155,9 +155,12 @@
   /// Server socket file descriptor
   THRIFT_SOCKET serverSocket_;
 
-  /// Port server runs on
+  /// Port server runs on. Zero when letting OS decide actual port
   int port_;
 
+  /// Port server actually runs on
+  int listenPort_;
+
   /// The optional user-provided event-base (for single-thread servers)
   event_base* userEventBase_;
 
@@ -280,6 +283,7 @@
     nextIOThread_ = 0;
     useHighPriorityIOThreads_ = false;
     port_ = port;
+    listenPort_ = port;
     userEventBase_ = NULL;
     threadPoolProcessing_ = false;
     numTConnections_ = 0;
@@ -395,6 +399,8 @@
 
   void setThreadManager(boost::shared_ptr<ThreadManager> threadManager);
 
+  int getListenPort() { return listenPort_; }
+
   boost::shared_ptr<ThreadManager> getThreadManager() { return threadManager_; }
 
   /**