[zeromq-dev] Invalid message
Pieter Hintjens
ph at imatix.com
Mon Jul 15 16:15:08 CEST 2013
Hi Guillaume,
The send method does not return true/false but the number of bytes
sent (I think), or -1. So test
if (b == -1) {
...
}
-Pieter
On Mon, Jul 15, 2013 at 12:24 PM, ... ... <bersac_1 at hotmail.fr> wrote:
> Hi,
>
> I am currently trying to develop a server using 0mq. The problem is that I
> keep having the same error message (retrieved using the zmq_strerror
> function) while sending the message :
> Resource temporarily unavailable.
> This correspond to the following error message number : eagain and
> approximatively mean : Non-blocking mode was requested and the message
> cannot be sent at the moment.
>
> My code is the following :
>
> int main ()
> {
> // Prepare our context and publisher
> zmq::context_t context (1);
> zmq::socket_t publisher (context, ZMQ_PUB);
> publisher.bind("ipc://weather.ipc");
>
> while (1) {
> int zipcode, temperature, relhumidity;
>
> // Get values that will fool the boss
> zipcode = within (100000);
> temperature = within (215) - 80;
> relhumidity = within (50) + 10;
>
> // Send message to all subscribers
>
> zmq::message_t message(20);
> snprintf ((char *) message.data(), 20 ,
> "%05d %d %d", zipcode, temperature, relhumidity);
>
> bool b = publisher.send(message);
> if(b){
> printf("%s.\n", zmq_strerror(errno));
> }
> sleep(1);
> }
> return 0;
> }
>
> This code is highly inspired by this example :
> http://zguide.zeromq.org/cpp:wuserver
> Could you help me find the source of my problem ?
>
> Cordially,
> Guillaume Bersac
> 237bis rue de Pessac
> 33000 Bordeaux
> 06.65.30.89.43
>
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
More information about the zeromq-dev
mailing list