ranch_tcp.asciidoc 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. = ranch_tcp(3)
  2. == Name
  3. ranch_tcp - TCP transport module
  4. == Description
  5. The `ranch_tcp` module implements a TCP Ranch transport.
  6. Note that due to bugs in OTP up to at least R16B02, it is
  7. recommended to disable async threads when using the
  8. `sendfile` function of this transport, as it can make
  9. the threads stuck indefinitely.
  10. == Types
  11. === opt()
  12. [source,erlang]
  13. ----
  14. opt() = {backlog, non_neg_integer()}
  15. | {buffer, non_neg_integer()}
  16. | {delay_send, boolean()}
  17. | {dontroute, boolean()}
  18. | {exit_on_close, boolean()}
  19. | {fd, non_neg_integer()}
  20. | {high_msgq_watermark, non_neg_integer()}
  21. | {high_watermark, non_neg_integer()}
  22. | inet
  23. | inet6
  24. | {ip, inet:ip_address()}
  25. | {keepalive, boolean()}
  26. | {linger, {boolean(), non_neg_integer()}}
  27. | {low_msgq_watermark, non_neg_integer()}
  28. | {low_watermark, non_neg_integer()}
  29. | {nodelay, boolean()}
  30. | {port, inet:port_number()}
  31. | {priority, integer()}
  32. | {raw, non_neg_integer(), non_neg_integer(), binary()}
  33. | {recbuf, non_neg_integer()}
  34. | {send_timeout, timeout()}
  35. | {send_timeout_close, boolean()}
  36. | {sndbuf, non_neg_integer()}
  37. | {tos, integer()}
  38. ----
  39. Listen options.
  40. This does not represent the entirety of the options that can
  41. be set on the socket, but only the options that may be
  42. set independently of protocol implementation.
  43. === opts() = [opt()]
  44. List of listen options.
  45. Option descriptions
  46. -------------------
  47. None of the options are required.
  48. Please consult the `gen_tcp` and `inet` manuals for a more
  49. thorough description of these options. This manual only aims
  50. to provide a short description along with what the defaults
  51. are. Defaults may be different in Ranch compared to `gen_tcp`.
  52. Defaults are given next to the option name.
  53. backlog (1024)::
  54. Max length of the queue of pending connections.
  55. buffer::
  56. Size of the buffer used by the Erlang driver. Default is system-dependent.
  57. delay_send (false)::
  58. Always queue packets before sending, to send fewer, larger packets over the network.
  59. dontroute (false)::
  60. Don't send via a gateway, only send to directly connected hosts.
  61. exit_on_close (true)::
  62. Disable to allow sending data after a close has been detected.
  63. fd::
  64. File descriptor of the socket, if it was opened externally.
  65. high_msgq_watermark (8192)::
  66. Limit in the amount of data in the socket message queue before the socket queue becomes busy.
  67. high_watermark (8192)::
  68. Limit in the amount of data in the ERTS socket implementation's queue before the socket becomes busy.
  69. inet::
  70. Set up the socket for IPv4.
  71. inet6::
  72. Set up the socket for IPv6.
  73. ip::
  74. Interface to listen on. Listen on all interfaces by default.
  75. keepalive (false)::
  76. Enable sending of keep-alive messages.
  77. linger ({false, 0})::
  78. Whether to wait and how long to flush data sent before closing the socket.
  79. low_msgq_watermark (4096)::
  80. Amount of data in the socket message queue before the socket queue leaves busy state.
  81. low_watermark (4096)::
  82. Amount of data in the ERTS socket implementation's queue before the socket leaves busy state.
  83. nodelay (true)::
  84. Whether to enable TCP_NODELAY.
  85. port (0)::
  86. TCP port number to listen on. 0 means a random port will be used.
  87. priority (0)::
  88. Priority value for all packets to be sent by this socket.
  89. recbuf::
  90. Minimum size of the socket's receive buffer. Default is system-dependent.
  91. send_timeout (30000)::
  92. How long the send call may wait for confirmation before returning.
  93. send_timeout_close (true)::
  94. Whether to close the socket when the confirmation wasn't received.
  95. sndbuf::
  96. Minimum size of the socket's send buffer. Default is system-dependent.
  97. tos::
  98. Value for the IP_TOS IP level option. Use with caution.
  99. In addition, the `raw` option can be used to set system-specific
  100. options by specifying the protocol level, the option number and
  101. the actual option value specified as a binary. This option is not
  102. portable. Use with caution.
  103. == Exports
  104. None.