aboutsummaryrefslogtreecommitdiffstats
path: root/src/ranch_tcp.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2013-12-07 15:03:05 +0100
committerLoïc Hoguin <[email protected]>2013-12-07 15:03:05 +0100
commit3634e392a8634eb716210204999f3b4c481dd4b1 (patch)
tree3ea65924ee298faffed892ebb536841037ee5fbb /src/ranch_tcp.erl
parent441687473ab364ba1cc5c19d89dced6a319747f9 (diff)
downloadranch-3634e392a8634eb716210204999f3b4c481dd4b1.tar.gz
ranch-3634e392a8634eb716210204999f3b4c481dd4b1.tar.bz2
ranch-3634e392a8634eb716210204999f3b4c481dd4b1.zip
Add transport options linger, send_timeout, send_timeout_close
Diffstat (limited to 'src/ranch_tcp.erl')
-rw-r--r--src/ranch_tcp.erl11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/ranch_tcp.erl b/src/ranch_tcp.erl
index d5d5003..27ecb3e 100644
--- a/src/ranch_tcp.erl
+++ b/src/ranch_tcp.erl
@@ -40,10 +40,13 @@
-type opts() :: [{backlog, non_neg_integer()}
| {ip, inet:ip_address()}
+ | {linger, {boolean(), non_neg_integer()}}
| {nodelay, boolean()}
| {port, inet:port_number()}
| {raw, non_neg_integer(), non_neg_integer(),
- non_neg_integer() | binary()}].
+ non_neg_integer() | binary()}
+ | {send_timeout, timeout()}
+ | {send_timeout_close, boolean()}].
-export_type([opts/0]).
%% @doc Name of this transport, <em>tcp</em>.
@@ -77,10 +80,14 @@ messages() -> {tcp, tcp_closed, tcp_error}.
-spec listen(opts()) -> {ok, inet:socket()} | {error, atom()}.
listen(Opts) ->
Opts2 = ranch:set_option_default(Opts, backlog, 1024),
+ Opts3 = ranch:set_option_default(Opts2, send_timeout, 30000),
+ Opts4 = ranch:set_option_default(Opts3, send_timeout_close, true),
%% 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, [backlog, ip, nodelay, port, raw],
+ gen_tcp:listen(0, ranch:filter_options(Opts4,
+ [backlog, ip, linger, nodelay, port, raw,
+ send_timeout, send_timeout_close],
[binary, {active, false}, {packet, raw},
{reuseaddr, true}, {nodelay, true}])).