From cd099983b1b807b87fa050d1e4ff0a13aba25b49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Wed, 26 Sep 2012 00:40:48 +0200 Subject: 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/ --- src/ranch_ssl.erl | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/ranch_ssl.erl') diff --git a/src/ranch_ssl.erl b/src/ranch_ssl.erl index 72b59db..1471f62 100644 --- a/src/ranch_ssl.erl +++ b/src/ranch_ssl.erl @@ -64,6 +64,7 @@ messages() -> {ssl, ssl_closed, ssl_error}. %% by default. %%
keyfile
Optional. Path to the file containing the user's %% private PEM encoded key.
+%%
nodelay
Optional. Enable TCP_NODELAY. Enabled by default.
%%
password
Optional. String containing the user's password. %% All private keyfiles must be password protected currently.
%%
port
TCP port number to open. Defaults to 0 (see below)
@@ -78,8 +79,8 @@ messages() -> {ssl, ssl_closed, ssl_error}. %% @see ssl:listen/2 -spec listen([{backlog, non_neg_integer()} | {cacertfile, string()} | {certfile, string()} | {ciphers, [ssl:erl_cipher_suite()] | string()} - | {ip, inet:ip_address()} | {keyfile, string()} | {password, string()} - | {port, inet:port_number()}]) + | {ip, inet:ip_address()} | {keyfile, string()} | {nodelay, boolean()} + | {password, string()} | {port, inet:port_number()}]) -> {ok, ssl:sslsocket()} | {error, atom()}. listen(Opts) -> ranch:require([crypto, public_key, ssl]), @@ -89,8 +90,10 @@ listen(Opts) -> %% The port in the options takes precedence over the one in the %% first argument. ssl:listen(0, ranch:filter_options(Opts2, - [backlog, cacertfile, certfile, ciphers, ip, keyfile, password, port], - [binary, {active, false}, {packet, raw}, {reuseaddr, true}])). + [backlog, cacertfile, certfile, ciphers, ip, + keyfile, nodelay, password, port], + [binary, {active, false}, {packet, raw}, + {reuseaddr, true}, {nodelay, true}])). %% @doc Accept connections with the given listening socket. %% -- cgit v1.2.3