nn_reqrep.adoc 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. nn_reqrep(7)
  2. ============
  3. NAME
  4. ----
  5. nn_reqrep - request/reply scalability protocol
  6. SYNOPSIS
  7. --------
  8. *#include <nanomsg/nn.h>*
  9. *#include <nanomsg/reqrep.h>*
  10. DESCRIPTION
  11. -----------
  12. This protocol is used to distribute the workload among multiple stateless
  13. workers.
  14. Please note that request/reply applications should be stateless.
  15. It's important to include all the information necessary to process the
  16. request in the request itself, including information about the sender or
  17. the originator of the request if this is necessary to respond to the request.
  18. Sender information cannot be retrieved from the underlying socket connection
  19. since, firstly, transports like IPC may not have a firm notion of a message
  20. origin. Secondly, transports that have some notion may not have a reliable one
  21. -- a TCP disconnect may mean a new sender, or it may mean a temporary loss in
  22. network connectivity.
  23. For this reason, sender information must be included by the application if
  24. required. Allocating 6 randomly-generated bytes in the message for the lifetime
  25. of the connection is sufficient for most purposes. For longer-lived
  26. applications, an UUID is more suitable.
  27. Socket Types
  28. ~~~~~~~~~~~~
  29. NN_REQ::
  30. Used to implement the client application that sends requests and
  31. receives replies.
  32. NN_REP::
  33. Used to implement the stateless worker that receives requests and sends
  34. replies.
  35. Socket Options
  36. ~~~~~~~~~~~~~~
  37. NN_REQ_RESEND_IVL::
  38. This option is defined on the full REQ socket. If reply is not received
  39. in specified amount of milliseconds, the request will be automatically
  40. resent. The type of this option is int. Default value is 60000 (1 minute).
  41. SEE ALSO
  42. --------
  43. <<nn_bus#,nn_bus(7)>>
  44. <<nn_pubsub#,nn_pubsub(7)>>
  45. <<nn_pipeline#,nn_pipeline(7)>>
  46. <<nn_survey#,nn_survey(7)>>
  47. <<nn_pair#,nn_pair(7)>>
  48. <<nanomsg#,nanomsg(7)>>
  49. AUTHORS
  50. -------
  51. link:mailto:sustrik@250bpm.com[Martin Sustrik]