zmq_msg_init.txt 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. zmq_msg_init(3)
  2. ===============
  3. NAME
  4. ----
  5. zmq_msg_init - initialise empty 0MQ message
  6. SYNOPSIS
  7. --------
  8. *int zmq_msg_init (zmq_msg_t '*msg');*
  9. DESCRIPTION
  10. -----------
  11. The _zmq_msg_init()_ function shall initialise the message object referenced by
  12. 'msg' to represent an empty message. This function is most useful when called
  13. before receiving a message with _zmq_msg_recv()_.
  14. CAUTION: Never access 'zmq_msg_t' members directly, instead always use the
  15. _zmq_msg_ family of functions.
  16. CAUTION: The functions _zmq_msg_init()_, _zmq_msg_init_data()_,
  17. _zmq_msg_init_size()_ and _zmq_msg_init_buffer()_ are mutually exclusive.
  18. Never initialise the same 'zmq_msg_t' twice.
  19. RETURN VALUE
  20. ------------
  21. The _zmq_msg_init()_ function always returns zero.
  22. ERRORS
  23. ------
  24. No errors are defined.
  25. EXAMPLE
  26. -------
  27. .Receiving a message from a socket
  28. ----
  29. zmq_msg_t msg;
  30. rc = zmq_msg_init (&msg);
  31. assert (rc == 0);
  32. int nbytes = zmq_msg_recv (socket, &msg, 0);
  33. assert (nbytes != -1);
  34. ----
  35. SEE ALSO
  36. --------
  37. linkzmq:zmq_msg_init_size[3]
  38. linkzmq:zmq_msg_init_buffer[3]
  39. linkzmq:zmq_msg_init_data[3]
  40. linkzmq:zmq_msg_close[3]
  41. linkzmq:zmq_msg_data[3]
  42. linkzmq:zmq_msg_size[3]
  43. linkzmq:zmq[7]
  44. AUTHORS
  45. -------
  46. This page was written by the 0MQ community. To make a change please
  47. read the 0MQ Contribution Policy at <http://www.zeromq.org/docs:contributing>.