Summary of some address helpers.
More...
#include <ZMQAddressUtils.h>
|
static std::string | randomSocketName (const std::string &hostname) |
| Generate a random socket name in the form tcp://hostname:port.
|
|
static std::string | randomSocketName () |
| Generate a random socket name in the form ipc:///socketname.
|
|
static std::string | getSocketAddress (const std::string &socketAddress, ZMQAddressType socketPart) |
| Create a full socket address for the given type from a random socket address, ba adding a suffix.
|
|
Summary of some address helpers.
Definition at line 27 of file ZMQAddressUtils.h.
◆ getSocketAddress()
std::string getSocketAddress |
( |
const std::string & |
socketAddress, |
|
|
ZMQAddressType |
socketPart |
|
) |
| |
|
static |
Create a full socket address for the given type from a random socket address, ba adding a suffix.
Definition at line 55 of file ZMQAddressUtils.cc.
56{
57 const std::string& prefix = "tcp://";
58 if (socketAddress.compare(0, prefix.size(), prefix) == 0) {
59 if (socketPart == ZMQAddressType::c_input) {
60 return socketAddress + "0";
62 return socketAddress + "1";
64 return socketAddress + "2";
66 return socketAddress + "3";
68 return socketAddress + "4";
69 }
70 } else {
71 if (socketPart == ZMQAddressType::c_input) {
72 return socketAddress + "_input";
74 return socketAddress + "_output";
76 return socketAddress + "_pub";
78 return socketAddress + "_sub";
80 return socketAddress + "_control";
81 }
82 }
83 return socketAddress;
84}
@ c_sub
Multicast publish socket.
@ c_control
Multicast subscribe socket.
◆ randomSocketName() [1/2]
std::string randomSocketName |
( |
| ) |
|
|
static |
Generate a random socket name in the form ipc:///socketname.
Definition at line 44 of file ZMQAddressUtils.cc.
45{
46
47 std::string socket_name = "ipc:///tmp/basf2_socket_" + randomName() + ".socket";
48 while (std::ifstream(socket_name)) {
49 socket_name = "ipc://basf2_socket_" + randomName() + ".socket";
50 }
51
52 return socket_name;
53}
◆ randomSocketName() [2/2]
std::string randomSocketName |
( |
const std::string & |
hostname | ) |
|
|
static |
Generate a random socket name in the form tcp://hostname:port.
Definition at line 38 of file ZMQAddressUtils.cc.
39{
40 std::string socket_name = "tcp://" + hostname + ":" + randomPort();
41 return socket_name;
42}
The documentation for this class was generated from the following files: