aboutsummaryrefslogtreecommitdiffstats
path: root/src/ranch.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/ranch.erl')
-rw-r--r--src/ranch.erl14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/ranch.erl b/src/ranch.erl
index 3a79312..6d1d5e8 100644
--- a/src/ranch.erl
+++ b/src/ranch.erl
@@ -47,13 +47,21 @@
%% of connections.
%%
%% <em>Ref</em> can be used to stop the listener later on.
+%%
+%% This function will return `{error, badarg}` if and only if the transport
+%% module given doesn't appear to be correct.
-spec start_listener(any(), non_neg_integer(), module(), any(), module(), any())
- -> {ok, pid()}.
+ -> {ok, pid()} | {error, badarg}.
start_listener(Ref, NbAcceptors, Transport, TransOpts, Protocol, ProtoOpts)
when is_integer(NbAcceptors) andalso is_atom(Transport)
andalso is_atom(Protocol) ->
- supervisor:start_child(ranch_sup, child_spec(Ref, NbAcceptors,
- Transport, TransOpts, Protocol, ProtoOpts)).
+ case erlang:function_exported(Transport, name, 0) of
+ false ->
+ {error, badarg};
+ true ->
+ supervisor:start_child(ranch_sup, child_spec(Ref, NbAcceptors,
+ Transport, TransOpts, Protocol, ProtoOpts))
+ end.
%% @doc Stop a listener identified by <em>Ref</em>.
%%