diff options
Diffstat (limited to 'docs/en/ranch/1.5/guide/protocols/index.html')
-rw-r--r-- | docs/en/ranch/1.5/guide/protocols/index.html | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/docs/en/ranch/1.5/guide/protocols/index.html b/docs/en/ranch/1.5/guide/protocols/index.html index a0d11047..124feaa0 100644 --- a/docs/en/ranch/1.5/guide/protocols/index.html +++ b/docs/en/ranch/1.5/guide/protocols/index.html @@ -67,7 +67,7 @@ <p>All protocol handlers must implement the <code>ranch_protocol</code> behavior which defines a single callback, <code>start_link/4</code>. This callback is responsible for spawning a new process for handling the connection. It receives four arguments: the name of the listener, the socket, the transport handler being used and the protocol options defined in the call to <code>ranch:start_listener/5</code>. This callback must return <code>{ok, Pid}</code>, with <code>Pid</code> the pid of the new process.</p> <p>The newly started process can then freely initialize itself. However, it must call <code>ranch:accept_ack/1</code> before doing any socket operation. This will ensure the connection process is the owner of the socket. It expects the listener's name as argument.</p> <div class="listingblock"><div class="title">Acknowledge accepting the socket</div> -<div class="content"><!-- Generator: GNU source-highlight 3.1.8 +<div class="content"><!-- Generator: GNU source-highlight 3.1.9 by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> @@ -76,7 +76,7 @@ http://www.gnu.org/software/src-highlite --> <p>If your protocol code requires specific socket options, you should set them while initializing your connection process, after calling <code>ranch:accept_ack/1</code>. You can use <code>Transport:setopts/2</code> for that purpose.</p> <p>Following is the complete protocol code for the example found in <code>examples/tcp_echo/</code>.</p> <div class="listingblock"><div class="title">Protocol module that echoes everything it receives</div> -<div class="content"><!-- Generator: GNU source-highlight 3.1.8 +<div class="content"><!-- Generator: GNU source-highlight 3.1.9 by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> @@ -107,7 +107,7 @@ http://www.gnu.org/software/src-highlite --> <p>Special processes like the ones that use the <code>gen_server</code> or <code>gen_fsm</code> behaviours have the particularity of having their <code>start_link</code> call not return until the <code>init</code> function returns. This is problematic, because you won't be able to call <code>ranch:accept_ack/1</code> from the <code>init</code> callback as this would cause a deadlock to happen.</p> <p>Use the <code>gen_server:enter_loop/3</code> function. It allows you to start your process normally (although it must be started with <code>proc_lib</code> like all special processes), then perform any needed operations before falling back into the normal <code>gen_server</code> execution loop.</p> <div class="listingblock"><div class="title">Use a gen_server for protocol handling</div> -<div class="content"><!-- Generator: GNU source-highlight 3.1.8 +<div class="content"><!-- Generator: GNU source-highlight 3.1.9 by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> |