Skip to content

Commit 6705c07

Browse files
garaemoneisoku9618
authored andcommitted
Resolve hostname as IP
1 parent 050ddcb commit 6705c07

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

prosilica_camera/src/nodes/prosilica_nodelet.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
#include <sensor_msgs/SetCameraInfo.h>
5050

5151
#include <boost/thread.hpp>
52+
#include <netdb.h>
53+
#include <arpa/inet.h>
5254

5355
#include <prosilica_camera/ProsilicaCameraConfig.h>
5456
#include "prosilica/prosilica.h"
@@ -253,6 +255,14 @@ class ProsilicaNodelet : public nodelet::Nodelet
253255
{
254256
state_info_ = "Trying to load camera with ipaddress: " + ip_address_;
255257
NODELET_INFO("%s", state_info_.c_str());
258+
/* Resolve hostname */
259+
struct hostent *he;
260+
if ((he = gethostbyname(ip_address_.c_str())) != NULL)
261+
{
262+
ip_address_ = std::string(inet_ntoa(*(struct in_addr*)(he->h_addr)));
263+
NODELET_INFO("ip resolved as %s", ip_address_.c_str());
264+
}
265+
256266
camera_ = boost::make_shared<prosilica::Camera>(ip_address_.c_str());
257267
guid_ = camera_->guid();
258268
hw_id_ = boost::lexical_cast<std::string>(guid_);

0 commit comments

Comments
 (0)