本文整理汇总了C++中zmq::socket_t::setsockopt方法的典型用法代码示例。如果您正苦于以下问题:C++ socket_t::setsockopt方法的具体用法?C++ socket_t::setsockopt怎么用?C++ socket_t::setsockopt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类zmq::socket_t
的用法示例。
在下文中一共展示了socket_t::setsockopt方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sprintf
// Set simple random printable identity on socket
//
static void
s_set_id (zmq::socket_t & socket)
{
char identity [10];
sprintf (identity, "%04X-%04X", within (0x10000), within (0x10000));
socket.setsockopt(ZMQ_IDENTITY, identity, strlen (identity));
}
示例2: Listen
void OTSocket::Listen(const OTString &strBind)
{
if (NULL != m_pSocket)
delete m_pSocket;
// m_pSocket = NULL;
m_pSocket = new zmq::socket_t(*m_pContext, ZMQ_REP); // RESPONSE socket (Request / Response.)
OT_ASSERT_MSG(NULL != m_pSocket, "OTSocket::Listen: new zmq::socket(context, ZMQ_REP)");
OTString strTemp(strBind); // In case m_strBindPath is what was passed in. (It happens.)
m_strBindPath.Set(strTemp); // In case we have to close/reopen the socket to finish a send/receive.
// ------------------------
// Configure socket to not wait at close time
//
const int linger = 0; // close immediately
m_pSocket->setsockopt (ZMQ_LINGER, &linger, sizeof (linger));
/*
int zmq_setsockopt (void *socket, int option_name, const void *option_value, size_t option_len);
Caution: All options, with the exception of ZMQ_SUBSCRIBE, ZMQ_UNSUBSCRIBE and ZMQ_LINGER, only take effect for subsequent socket bind/connects.
*/
// ------------------------
m_pSocket->bind(strBind.Get());
}
示例3:
// Fix #521
inline std::string
s_set_id(zmq::socket_t & socket, intptr_t id)
{
std::stringstream ss;
ss << std::hex << std::uppercase
<< std::setw(4) << std::setfill('0') << id;
socket.setsockopt(ZMQ_IDENTITY, ss.str().c_str(), ss.str().length());
return ss.str();
}
示例4: within
// Set simple random printable identity on socket
//
inline std::string
s_set_id (zmq::socket_t & socket)
{
std::stringstream ss;
ss << std::hex << std::uppercase
<< std::setw(4) << std::setfill('0') << within (0x10000) << "-"
<< std::setw(4) << std::setfill('0') << within (0x10000);
socket.setsockopt(ZMQ_IDENTITY, ss.str().c_str(), ss.str().length());
return ss.str();
}
示例5: ConnectToStateServer
void ServerInterface::ConnectToStateServer(zmq::socket_t& stateSocket) const {
std::cout << "Connecting to state server " << m_stateServer << std::endl;
stateSocket.connect(m_stateServer.c_str());
stateSocket.setsockopt(ZMQ_SUBSCRIBE, m_matchToken.c_str(), m_matchToken.size());
}
示例6: setSocketID
void setSocketID(const std::string& id, zmq::socket_t & socket)
{
socket.setsockopt(ZMQ_IDENTITY, id.c_str(), id.length());
}