nn_device.adoc 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. nn_device(3)
  2. ============
  3. NAME
  4. ----
  5. nn_device - start a device
  6. SYNOPSIS
  7. --------
  8. *#include <nanomsg/nn.h>*
  9. *int nn_device (int 's1', int 's2');*
  10. DESCRIPTION
  11. -----------
  12. Starts a device to forward messages between two sockets. If both sockets are
  13. valid, _nn_device_ function loops and sends any messages received from 's1' to
  14. 's2' and vice versa. If only one socket is valid and the other is negative,
  15. _nn_device_ works in a "loopback" mode -- it loops and sends any messages
  16. received from the socket back to itself.
  17. To break the loop and make _nn_device_ function exit use the
  18. <<nn_term#,nn_term(3)>> function.
  19. RETURN VALUE
  20. ------------
  21. The function loops until it hits an error. In such a case it returns -1
  22. and sets 'errno' to one of the values defined below.
  23. ERRORS
  24. ------
  25. *EBADF*::
  26. One of the provided sockets is invalid.
  27. *EINVAL*::
  28. Either one of the socket is not an AF_SP_RAW socket; or the two sockets don't
  29. belong to the same protocol; or the directionality of the sockets doesn't fit
  30. (e.g. attempt to join two SINK sockets to form a device).
  31. *EINTR*::
  32. The operation was interrupted by delivery of a signal.
  33. *ETERM*::
  34. The library is terminating.
  35. EXAMPLE
  36. -------
  37. ----
  38. int s1 = nn_socket (AF_SP_RAW, NN_REQ);
  39. nn_bind (s1, "tcp://127.0.0.1:5555");
  40. int s2 = nn_socket (AF_SP_RAW, NN_REP);
  41. nn_bind (s2, "tcp://127.0.0.1:5556");
  42. nn_device (s1, s2);
  43. ----
  44. SEE ALSO
  45. --------
  46. <<nn_socket#,nn_socket(3)>>
  47. <<nn_term#,nn_term(3)>>
  48. <<nanomsg#,nanomsg(7)>>
  49. AUTHORS
  50. -------
  51. link:mailto:sustrik@250bpm.com[Martin Sustrik]