DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
ZmqUri.cpp
Go to the documentation of this file.
1
10#include "utilities/ZmqUri.hpp"
11#include "utilities/get_ips.hpp"
12#include "utilities/Issues.hpp"
13
14#include <string>
15#include <vector>
16
17
18// ZMQ URIs are formatted as follows: tcp://{host}:{port}
19dunedaq::utilities::ZmqUri::ZmqUri(std::string connection_string)
20{
21 if (connection_string.find("://") == std::string::npos) {
22 throw InvalidUri(ERS_HERE, connection_string);
23 }
24
25 scheme = connection_string.substr(0, connection_string.find("://"));
26 connection_string = connection_string.substr(connection_string.find("://") + 3);
27
28 if (connection_string.find(":") != std::string::npos) {
29 port = connection_string.substr(connection_string.find(":") + 1);
30 connection_string = connection_string.substr(0, connection_string.find(":"));
31 }
32 host = connection_string;
33}
34
35std::vector<std::string>
37{
38 if (scheme == "tcp") {
39 auto output = get_hostname_ips(host);
40
41 for (size_t ii = 0; ii < output.size(); ++ii) {
42 output[ii] = "tcp://" + output[ii] + ":" + port;
43 }
44 return output;
45 } else {
46 return { to_string() };
47 }
48}
#define ERS_HERE
std::vector< std::string > get_hostname_ips(std::string hostname)
Definition get_ips.hpp:31
ZmqUri(std::string connection_string)
Definition ZmqUri.cpp:19
std::vector< std::string > get_uri_ip_addresses()
Definition ZmqUri.cpp:36