commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 30/50: controlport: ephemeral / unused port


From: git
Subject: [Commit-gnuradio] [gnuradio] 30/50: controlport: ephemeral / unused port number selection by OS working.
Date: Wed, 15 Apr 2015 21:07:55 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

jcorgan pushed a commit to branch master
in repository gnuradio.

commit d4a63e49a528140b678f14509d23d954da84110e
Author: Nate Goergen <address@hidden>
Date:   Tue Mar 3 21:48:42 2015 -0600

    controlport: ephemeral / unused port number selection by OS working.
    
    Have hostname resolution working. However, it looks like a delay is
    needed before reading the Thrift TServerSocket::getPort() function to
    get a vaild port number from bind(), as the first few calls to
    TServerSocket:getPort() return '0' (i.e. what we specified) and not
    the OS selected port number.
---
 .../include/gnuradio/thrift_server_template.h         | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/gnuradio-runtime/include/gnuradio/thrift_server_template.h 
b/gnuradio-runtime/include/gnuradio/thrift_server_template.h
index ff025b0..9972dd2 100644
--- a/gnuradio-runtime/include/gnuradio/thrift_server_template.h
+++ b/gnuradio-runtime/include/gnuradio/thrift_server_template.h
@@ -37,6 +37,9 @@
 #include <thrift/transport/TBufferTransports.h>
 #include "thrift/ControlPort.h"
 
+//#include <netdb.h>
+#include <boost/asio/ip/host_name.hpp>
+
 using namespace apache;
 
 namespace {
@@ -170,13 +173,25 @@ thrift_server_template<TserverBase, 
TserverClass,TImplClass, TThriftClass>::~thr
 template<typename TserverBase, typename TserverClass, typename TImplClass, 
typename TThriftClass>
 TserverBase* thrift_server_template<TserverBase, TserverClass, TImplClass, 
TThriftClass>::i_impl()
 {
-  //std::cerr << "thrift_server_template: i_impl" << std::endl;
+  std::cerr << "thrift_server_template: i_impl" << std::endl;
+
+//     char hostname[1024];
+//     hostname[1023] = '\0';
+//     ::gethostname(hostname, 1023);
+//     ::printf("Hostname: %s\n", hostname);
+//     struct hostent* h;
+//     h = ::gethostbyname(hostname);
+//     ::printf("h_name: %s\n", h->h_name);
+
+       const std::string boost_hostname(boost::asio::ip::host_name());
+       //std::cout << "boost hostname: " << boost_hostname << std::endl;
 
   // Define the endpoint
   thrift::transport::TServerTransport *thetransport =
     thrift_application_base<TserverBase, 
TImplClass>::d_thriftserver->getServerTransport().get();
   int used_port = ((thrift::transport::TServerSocket*)thetransport)->getPort();
-  std::string endpoint = boost::str(boost::format("%1% -p %2%") % "127.0.0.1" 
% used_port);
+  std::string endpoint = boost::str(boost::format("%1% -p %2%") % 
boost_hostname % used_port);
+  std::cout << "Thrift endpoint: " << endpoint << " boost hostname: " << 
boost_hostname << std::endl;
   thrift_application_base<TserverBase, 
TImplClass>::d_this->set_endpoint(endpoint);
 
   return d_server;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]