[zeromq-dev] nzmqt question: how to stop?

Marco Trapanese marcotrapanese at gmail.com
Sun May 27 09:57:33 CEST 2012


Il 26/05/2012 18:50, Marco Trapanese ha scritto:

> I'd recommend myself to set the linger option...


Yet another lack in my knowledge. I read the doc about the HWM option 
and I found this example (durable but cynical publisher):

void *context = zmq_init (1);
void *publisher = zmq_socket (context, ZMQ_PUB);
uint64_t hwm = 1;	// I won't set to one, btw
zmq_setsockopt (publisher, ZMQ_HWM, &hwm, sizeof (hwm));
zmq_bind (publisher, "tcp://*:5565")


But when in my code I write this:

FemtoServer::FemtoServer(QString serverAddr, QObject *parent) : 
QObject(parent), m_serverAddr(serverAddr) {
     m_dealers.clear();
     ZMQContext* context = createDefaultContext(this);
     context->start();
     m_socket = context->createSocket(ZMQSocket::TYP_ROUTER);
     m_socket->setLinger(0);
     connect(m_socket, SIGNAL(messageReceived(const 
QList<QByteArray>&)), this, SLOT(requestReceived(const 
QList<QByteArray>&)));
}

void FemtoServer::run() {
     m_socket->setOption(ZMQSocket::OPT_HWM, 8); // here the error fires
     m_socket->bindTo(m_serverAddr);
}

The program crashes and returns:

terminate called after throwing an instance of 'zmq::error_t'
   what():  Argomento non valido


Is there any evidence of mistakes?

Thanks!
Marco




More information about the zeromq-dev mailing list