> > Another crazy hack suggestion: if you change the representation of
> context to also be an integer handle, you could encode the {context,
> socket} pair as two 16 bit (unsigned) integers packed into a 32 bit
> (unsigned) integer.  Advantages:
> 
> How would you implement this without using globals?

Something like this:

  int ctx = zmq_init();
  int sock = zmq_socket(ctx, TYPE);
  // The upper 16 bits of sock now contain ctx;
  // the lower 16 bits contain the actual sock number.
  // You might even use less bits for ctx.

  // From now on, passing sock implicitly passes in ctx as well
  zmq_connect(sock, "blah");
  int rc = 0;
  rc = zmq_send(sock, &msg, flags);
  // ...
  rc = zmq_recv(sock, &msg, flags);

Admittedly a hack. Regards.

-- 
Gonzalo Diethelm

----------------------------------------- 
Declaración de confidencialidad: Este Mensaje esta destinado para
el uso de la o las personas o entidades a quien ha sido dirigido y
puede contener información reservada y confidencial que no puede
ser divulgada, difundida, ni aprovechada en forma alguna. El uso no
autorizado de la información contenida en este correo podrá ser
sancionado de conformidad con la ley chilena. 
Si usted ha recibido este correo electrónico por error, le pedimos
eliminarlo junto con los archivos adjuntos y avisar inmediatamente
al remitente, respondiendo este mensaje. 

"Before printing this e-mail think if is really necesary".
Disclosure: This Message is to be used by the individual,
individuals or entities that it is addressed to and may include
private and confidential information that may not be disclosed,
made public nor used in any way at all. Unauthorized use of the
information in this electronic mail message may be subject to the
penalties set forth by Chilean law. 
If you have received this electronic mail message in error, we ask
you to destroy the message and its attached file(s) and to
immediately notify the sender by answering this message. 
_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to