zmq_bind.txt 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. zmq_bind(3)
  2. ===========
  3. NAME
  4. ----
  5. zmq_bind - accept incoming connections on a socket
  6. SYNOPSIS
  7. --------
  8. *int zmq_bind (void '*socket', const char '*endpoint');*
  9. DESCRIPTION
  10. -----------
  11. The _zmq_bind()_ function binds the 'socket' to a local 'endpoint' and then
  12. accepts incoming connections on that endpoint.
  13. The 'endpoint' is a string consisting of a 'transport'`://` followed by an
  14. 'address'. The 'transport' specifies the underlying protocol to use. The
  15. 'address' specifies the transport-specific address to bind to.
  16. 0MQ provides the the following transports:
  17. 'tcp':: unicast transport using TCP, see linkzmq:zmq_tcp[7]
  18. 'ipc':: local inter-process communication transport, see linkzmq:zmq_ipc[7]
  19. 'inproc':: local in-process (inter-thread) communication transport, see linkzmq:zmq_inproc[7]
  20. 'pgm', 'epgm':: reliable multicast transport using PGM, see linkzmq:zmq_pgm[7]
  21. 'vmci':: virtual machine communications interface (VMCI), see linkzmq:zmq_vmci[7]
  22. 'udp':: unreliable unicast and multicast using UDP, see linkzmq:zmq_udp[7]
  23. Every 0MQ socket type except 'ZMQ_PAIR' and 'ZMQ_CHANNEL' supports one-to-many and many-to-one
  24. semantics. The precise semantics depend on the socket type and are defined in
  25. linkzmq:zmq_socket[3].
  26. The 'ipc', 'tcp', 'vmci' and 'udp' transports accept wildcard addresses: see
  27. linkzmq:zmq_ipc[7], linkzmq:zmq_tcp[7], linkzmq:zmq_vmci[7] and
  28. linkzmq:zmq_udp[7] for details.
  29. NOTE: the address syntax may be different for _zmq_bind()_ and _zmq_connect()_
  30. especially for the 'tcp', 'pgm' and 'epgm' transports.
  31. NOTE: following a _zmq_bind()_, the socket enters a 'mute' state unless or
  32. until at least one incoming or outgoing connection is made, at which point
  33. the socket enters a 'ready' state. In the mute state, the socket blocks or
  34. drops messages according to the socket type, as defined in linkzmq:zmq_socket[3].
  35. By contrast, following a libzmq:zmq_connect[3], the socket enters the 'ready' state.
  36. RETURN VALUE
  37. ------------
  38. The _zmq_bind()_ function returns zero if successful. Otherwise it returns
  39. `-1` and sets 'errno' to one of the values defined below.
  40. ERRORS
  41. ------
  42. *EINVAL*::
  43. The endpoint supplied is invalid.
  44. *EPROTONOSUPPORT*::
  45. The requested 'transport' protocol is not supported.
  46. *ENOCOMPATPROTO*::
  47. The requested 'transport' protocol is not compatible with the socket type.
  48. *EADDRINUSE*::
  49. The requested 'address' is already in use.
  50. *EADDRNOTAVAIL*::
  51. The requested 'address' was not local.
  52. *ENODEV*::
  53. The requested 'address' specifies a nonexistent interface.
  54. *ETERM*::
  55. The 0MQ 'context' associated with the specified 'socket' was terminated.
  56. *ENOTSOCK*::
  57. The provided 'socket' was invalid.
  58. *EMTHREAD*::
  59. No I/O thread is available to accomplish the task.
  60. EXAMPLE
  61. -------
  62. .Binding a publisher socket to an in-process and a TCP transport
  63. ----
  64. /* Create a ZMQ_PUB socket */
  65. void *socket = zmq_socket (context, ZMQ_PUB);
  66. assert (socket);
  67. /* Bind it to a in-process transport with the address 'my_publisher' */
  68. int rc = zmq_bind (socket, "inproc://my_publisher");
  69. assert (rc == 0);
  70. /* Bind it to a TCP transport on port 5555 of the 'eth0' interface */
  71. rc = zmq_bind (socket, "tcp://eth0:5555");
  72. assert (rc == 0);
  73. ----
  74. SEE ALSO
  75. --------
  76. linkzmq:zmq_connect[3]
  77. linkzmq:zmq_socket[3]
  78. linkzmq:zmq[7]
  79. AUTHORS
  80. -------
  81. This page was written by the 0MQ community. To make a change please
  82. read the 0MQ Contribution Policy at <http://www.zeromq.org/docs:contributing>.