diff options
author | Loïc Hoguin <[email protected]> | 2012-09-26 00:40:48 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2012-09-26 00:41:27 +0200 |
commit | cd099983b1b807b87fa050d1e4ff0a13aba25b49 (patch) | |
tree | 844af725fa7102dd1c532aebecce1bf927c83450 /src/ranch_tcp.erl | |
parent | de9b6f7a707efd308a6d6535d8296c15ea277308 (diff) | |
download | ranch-cd099983b1b807b87fa050d1e4ff0a13aba25b49.tar.gz ranch-cd099983b1b807b87fa050d1e4ff0a13aba25b49.tar.bz2 ranch-cd099983b1b807b87fa050d1e4ff0a13aba25b49.zip |
Add the {nodelay, boolean()} option controlling TCP_NODELAY
Enabled by default.
A comprehensive explanation about TCP_NODELAY and the Nagle algorithm
can be found at http://www.stuartcheshire.org/papers/NagleDelayedAck/
Diffstat (limited to 'src/ranch_tcp.erl')
-rw-r--r-- | src/ranch_tcp.erl | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/ranch_tcp.erl b/src/ranch_tcp.erl index 2a9ccd6..18322db 100644 --- a/src/ranch_tcp.erl +++ b/src/ranch_tcp.erl @@ -50,6 +50,7 @@ messages() -> {tcp, tcp_closed, tcp_error}. %% Defaults to 1024.</dd> %% <dt>ip</dt><dd>Interface to listen on. Listen on all interfaces %% by default.</dd> +%% <dt>nodelay</dt><dd>Optional. Enable TCP_NODELAY. Enabled by default.</dd> %% <dt>port</dt><dd>TCP port number to open. Defaults to 0 (see below).</dd> %% </dl> %% @@ -61,15 +62,16 @@ messages() -> {tcp, tcp_closed, tcp_error}. %% %% @see gen_tcp:listen/2 -spec listen([{backlog, non_neg_integer()} | {ip, inet:ip_address()} - | {port, inet:port_number()}]) + | {nodelay, boolean()} | {port, inet:port_number()}]) -> {ok, inet:socket()} | {error, atom()}. listen(Opts) -> Opts2 = ranch:set_option_default(Opts, backlog, 1024), %% We set the port to 0 because it is given in the Opts directly. %% The port in the options takes precedence over the one in the %% first argument. - gen_tcp:listen(0, ranch:filter_options(Opts2, [port, ip, backlog], - [binary, {active, false}, {packet, raw}, {reuseaddr, true}])). + gen_tcp:listen(0, ranch:filter_options(Opts2, [backlog, ip, nodelay, port], + [binary, {active, false}, {packet, raw}, + {reuseaddr, true}, {nodelay, true}])). %% @doc Accept connections with the given listening socket. %% @see gen_tcp:accept/2 |