From 261e325883646912c880f2a1f2256b55eb7dcee9 Mon Sep 17 00:00:00 2001 From: Geoff Cant Date: Thu, 7 Nov 2013 13:17:22 -0800 Subject: Implements ranch_transport:connect/4. Adds a transport connect method that takes a timeout, with implementations for both ssl and tcp connections. --- src/ranch_tcp.erl | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/ranch_tcp.erl') diff --git a/src/ranch_tcp.erl b/src/ranch_tcp.erl index 6bdcdd0..abf7612 100644 --- a/src/ranch_tcp.erl +++ b/src/ranch_tcp.erl @@ -25,6 +25,7 @@ -export([listen/1]). -export([accept/2]). -export([connect/3]). +-export([connect/4]). -export([recv/3]). -export([send/2]). -export([sendfile/2]). @@ -99,6 +100,18 @@ connect(Host, Port, Opts) when is_integer(Port) -> gen_tcp:connect(Host, Port, Opts ++ [binary, {active, false}, {packet, raw}]). +%% @private Experimental. Open a connection to the given host and port +%% number with a timeout. +%% @see gen_tcp:connect/4 +%% @todo Probably filter Opts? +-spec connect(inet:ip_address() | inet:hostname(), + inet:port_number(), any(), timeout()) + -> {ok, inet:socket()} | {error, atom()}. +connect(Host, Port, Opts, Timeout) when is_integer(Port) -> + gen_tcp:connect(Host, Port, + Opts ++ [binary, {active, false}, {packet, raw}], + Timeout). + %% @doc Receive data from a socket in passive mode. %% @see gen_tcp:recv/3 -spec recv(inet:socket(), non_neg_integer(), timeout()) -- cgit v1.2.3