nn_socket.adoc 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. nn_socket(3)
  2. ============
  3. NAME
  4. ----
  5. nn_socket - create an SP socket
  6. SYNOPSIS
  7. --------
  8. *#include <nanomsg/nn.h>*
  9. *int nn_socket (int 'domain', int 'protocol');*
  10. DESCRIPTION
  11. -----------
  12. Creates an SP socket with specified 'domain' and 'protocol'. Returns a file
  13. descriptor for the newly created socket.
  14. Following domains are defined at the moment:
  15. *AF_SP*::
  16. Standard full-blown SP socket.
  17. *AF_SP_RAW*::
  18. Raw SP socket. Raw sockets omit the end-to-end functionality found in AF_SP
  19. sockets and thus can be used to implement intermediary devices in SP topologies.
  20. 'protocol' parameter defines the type of the socket, which in turn determines
  21. the exact semantics of the socket. Check manual pages for individual SP
  22. protocols to get the list of available socket types.
  23. The newly created socket is initially not associated with any endpoints.
  24. In order to establish a message flow at least one endpoint has to be added
  25. to the socket using <<nn_bind#,nn_bind(3)>> or <<nn_connect#,nn_connect(3)>>
  26. function.
  27. Also note that 'type' argument as found in standard _socket(2)_ function is
  28. omitted from _nn_socket_. All the SP sockets are message-based and thus of
  29. _SOCK_SEQPACKET_ type.
  30. RETURN VALUE
  31. ------------
  32. If the function succeeds file descriptor of the new socket is returned.
  33. Otherwise, -1 is returned and 'errno' is set to to one of
  34. the values defined below.
  35. Note that file descriptors returned by _nn_socket_ function are not standard
  36. file descriptors and will exhibit undefined behaviour when used with system
  37. functions. Moreover, it may happen that a system file descriptor and file
  38. descriptor of an SP socket will incidentally collide (be equal).
  39. ERRORS
  40. ------
  41. *EAFNOSUPPORT*::
  42. Specified address family is not supported.
  43. *EINVAL*::
  44. Unknown protocol.
  45. *EMFILE*::
  46. The limit on the total number of open SP sockets or OS limit for file
  47. descriptors has been reached.
  48. *ETERM*::
  49. The library is terminating.
  50. EXAMPLE
  51. -------
  52. ----
  53. int s = nn_socket (AF_SP, NN_PUB);
  54. assert (s >= 0);
  55. ----
  56. SEE ALSO
  57. --------
  58. <<nn_pubsub#,nn_pubsub(7)>>
  59. <<nn_reqrep#,nn_reqrep(7)>>
  60. <<nn_pipeline#,nn_pipeline(7)>>
  61. <<nn_survey#,nn_survey(7)>>
  62. <<nn_bus#,nn_bus(7)>>
  63. <<nn_bind#,nn_bind(3)>>
  64. <<nn_connect#,nn_connect(3)>>
  65. <<nn_close#,nn_close(3)>>
  66. <<nanomsg#,nanomsg(7)>>
  67. AUTHORS
  68. -------
  69. link:mailto:sustrik@250bpm.com[Martin Sustrik]