ranch_protocol.asciidoc 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. = ranch_protocol(3)
  2. == Name
  3. ranch_protocol - Protocol modules
  4. == Description
  5. The module `ranch_protocol` defines the interface used
  6. by Ranch protocols.
  7. == Callbacks
  8. Ranch protocols implement the following interface:
  9. [source,erlang]
  10. ----
  11. start_link(Ref :: ranch:ref(),
  12. Transport :: module(),
  13. ProtoOpts :: any())
  14. -> {ok, ConnPid :: pid()}
  15. | {ok, SupPid :: pid(), ConnPid :: pid()}
  16. ----
  17. Start a new connection process.
  18. The only purpose of this callback is to start a process that
  19. will handle the socket. It must spawn the process, link and
  20. then return the new pid. This function will always be called
  21. from inside a supervisor.
  22. This callback can also return two pids. The first pid is the
  23. pid of the process that will be supervised. The second pid is
  24. the pid of the process that will receive ownership of the
  25. socket. This second process must be a child of the first. This
  26. form is only available when `connection_type` is set to
  27. `supervisor`.
  28. If any other value is returned, the supervisor will close the
  29. socket and assume no process has been started.
  30. Do not perform any operations in this callback, as this would
  31. block the supervisor responsible for starting connection
  32. processes and degrade performance severely.
  33. == Changelog
  34. * *2.0*: The second argument `Socket` was removed.
  35. * *1.6*: The second argument `Socket` was deprecated. Call
  36. link:man:ranch:handshake(3)[ranch:handshake(3)]
  37. to obtain the socket.
  38. == See also
  39. link:man:ranch:handshake(3)[ranch:handshake(3)],
  40. link:man:ranch(7)[ranch(7)]