public static bool exists(string service_name, bool print_failure_reason)
{
string mapped_name = names.resolve(service_name);
string host = "";
int port = 0;
if (ServiceManager.Instance.lookUpService(mapped_name, ref host, ref port))
{
TcpTransport transport = new TcpTransport();
IDictionary m = new Hashtable
{
{ "probe", "1" },
{ "md5sum", "*" },
{ "callerid", this_node.Name },
{ "service", mapped_name }
};
byte[] headerbuf = null;
int size = 0;
Header h = new Header();
h.Write(m, ref headerbuf, ref size);
if (transport.connect(host, port))
{
byte[] sizebuf = BitConverter.GetBytes(size);
transport.write(sizebuf, 0, sizebuf.Length);
transport.write(headerbuf, 0, size);
return(true);
}
if (print_failure_reason)
{
ROS.Info("waitForService: Service[{0}] could not connect to host [{1}:{2}], waiting...", mapped_name, host, port);
}
}
else if (print_failure_reason)
{
ROS.Info("waitForService: Service[{0}] has not been advertised, waiting...", mapped_name);
}
return(false);
}