#include <execinfo.h>
#endif
+#include <netdb.h>
+#include <arpa/inet.h>
#include <memory>
#include <functional>
return p;
}
+ std::string GetIpByHostname() {
+ std::string host = GetHostname();
+ hostent* hostname = gethostbyname(host.c_str());
+ if(hostname)
+ return std::string(inet_ntoa(**(in_addr**)hostname->h_addr_list));
+ return {};
+ }
+
Localizer::Localizer()
{
init(LC_NUMERIC, "C");
#include <iostream>
#include "SalomeZeroMQ.hxx"
+#include "Basics_Utils.hxx"
DataZMQ::DataZMQ()
{
this->cont = zmq::context_t(1);
- this->addr = "inproc://hello";
+ this->addr = "tcp://" + Kernel_Utils::GetIpByHostname() + ":*";
this->sock = zmq::socket_t(this->cont, zmq::socket_type::pair);
}
char port[1024];
size_t size = sizeof(port);
try{
- this->sock.bind("tcp://*:*");
+ this->sock.bind(this->addr);
+ sock.getsockopt( ZMQ_LAST_ENDPOINT, &port, &size );
+ std::cout << "socket is bound at port " << port << std::endl;
+ this->addr = std::string(port);
}
catch (zmq::error_t&e ){
std::cerr << "couldn't bind to socket: " << e.what();
}
- sock.getsockopt( ZMQ_LAST_ENDPOINT, &port, &size );
- std::cout << "socket is bound at port " << port << std::endl;
- this->addr = std::string(port);
}
void DataZMQ::sendDataZMQ(const char* data, int len)