You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@thrift.apache.org by Gianni Ambrosio <gi...@vi-grade.com> on 2018/10/16 15:22:53 UTC
Connection to an empty IP address unexpectedly works
Dear All,
in the following code, transport->open() call works fine even if
ipAddress is an empty string. Why?
boost::shared_ptr<apache::thrift::transport::TSocket> socket(new
apache::thrift::transport::TSocket(ipAddress.c_str(),
g_DaemonService_constants.DaemonService_port));
socket->setConnTimeout(connectionTimeout);
transport =
boost::make_shared<apache::thrift::transport::TBufferedTransport>(socket);
client =
boost::make_shared<DaemonServiceClient>(boost::make_shared<apache::thrift::protocol::TBinaryProtocol>(transport));
transport->open();
Kind regards,
Gianni
Re: Connection to an empty IP address unexpectedly works
Posted by "James E. King III" <jk...@apache.org>.
Assuming the behavior is that it connects on loopback? You did not specify
the behavior
you are seeing. Best guess is that your platform's getaddrinfo()
implementation treats an
empty "node" argument the same way it would treat a NULL, which means the
address
returned is suitable for local connections.
Also, you don't need to convert ipAddress to c_str() if it is already a
std::string.
The constructor takes a const string ref, so this conversion to c_str() is
totally
unnecessary.
- Jim