diff options
Diffstat (limited to 'guide/protocols.md')
-rw-r--r-- | guide/protocols.md | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/guide/protocols.md b/guide/protocols.md index 7db8fec..94fc1c0 100644 --- a/guide/protocols.md +++ b/guide/protocols.md @@ -10,16 +10,16 @@ protocol logic executed in this process. Writing a protocol handler -------------------------- -All protocol handlers must implement the ```ranch_protocol``` behavior -which defines a single callback, ```start_link/4```. This callback is +All protocol handlers must implement the `ranch_protocol` behavior +which defines a single callback, `start_link/4`. This callback is responsible for spawning a new process for handling the connection. It receives four arguments: the listener's pid, the socket, the transport handler being used and the protocol options defined in -the call to ```ranch:start_listener/6```. This callback must -return ```{ok, Pid}```, with ```Pid``` the pid of the new process. +the call to `ranch:start_listener/6`. This callback must +return `{ok, Pid}`, with `Pid` the pid of the new process. The newly started process can then freely initialize itself. However, -it must call ```ranch:accept_ack/1``` before doing any socket operation. +it must call `ranch:accept_ack/1` before doing any socket operation. This will ensure the connection process is the owner of the socket. It expects the listener's pid as argument. @@ -29,11 +29,11 @@ ok = ranch:accept_ack(ListenerPid). If your protocol code requires specific socket options, you should set them while initializing your connection process and before -starting ```ranch:accept_ack/1```. You can use ```Transport:setopts/2``` +starting `ranch:accept_ack/1`. You can use `Transport:setopts/2` for that purpose. Following is the complete protocol code for the example found -in ```examples/tcp_echo/```. +in `examples/tcp_echo/`. ``` erlang -module(echo_protocol). |