Belle II Software light-2406-ragdoll
ZMQAddressUtils Class Reference

Summary of some address helpers. More...

#include <ZMQAddressUtils.h>

Static Public Member Functions

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.
 

Detailed Description

Summary of some address helpers.

Definition at line 27 of file ZMQAddressUtils.h.

Member Function Documentation

◆ 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";
61 } else if (socketPart == ZMQAddressType::c_output) {
62 return socketAddress + "1";
63 } else if (socketPart == ZMQAddressType::c_pub) {
64 return socketAddress + "2";
65 } else if (socketPart == ZMQAddressType::c_sub) {
66 return socketAddress + "3";
67 } else if (socketPart == ZMQAddressType::c_control) {
68 return socketAddress + "4";
69 }
70 } else {
71 if (socketPart == ZMQAddressType::c_input) {
72 return socketAddress + "_input";
73 } else if (socketPart == ZMQAddressType::c_output) {
74 return socketAddress + "_output";
75 } else if (socketPart == ZMQAddressType::c_pub) {
76 return socketAddress + "_pub";
77 } else if (socketPart == ZMQAddressType::c_sub) {
78 return socketAddress + "_sub";
79 } else if (socketPart == ZMQAddressType::c_control) {
80 return socketAddress + "_control";
81 }
82 }
83 return socketAddress;
84}
@ c_sub
Multicast publish socket.
@ c_control
Multicast subscribe socket.
@ c_pub
Output socket.
@ c_output
Input 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 // std::string socket_name = "ipc://basf2_socket_" + randomName() + ".socket";
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: