diff options
Diffstat (limited to 'src/ranch_transport.erl')
-rw-r--r-- | src/ranch_transport.erl | 56 |
1 files changed, 1 insertions, 55 deletions
diff --git a/src/ranch_transport.erl b/src/ranch_transport.erl index 5cf10d1..33c6fad 100644 --- a/src/ranch_transport.erl +++ b/src/ranch_transport.erl @@ -1,4 +1,4 @@ -%% Copyright (c) 2012, Loïc Hoguin <[email protected]> +%% Copyright (c) 2012-2013, Loïc Hoguin <[email protected]> %% %% Permission to use, copy, modify, and/or distribute this software for any %% purpose with or without fee is hereby granted, provided that the above @@ -12,7 +12,6 @@ %% ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF %% OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -%% @private -module(ranch_transport). -export([sendfile/6]). @@ -22,92 +21,39 @@ -type sendfile_opts() :: [{chunk_size, non_neg_integer()}]. -export_type([sendfile_opts/0]). -%% Name of the transport. -callback name() -> atom(). - %% @todo -callback caps(secure | sendfile) -> boolean(). - -%% Atoms used to identify messages in {active, once | true} mode. -callback messages() -> {OK::atom(), Closed::atom(), Error::atom()}. - -%% Listen for connections on the given port number. -%% -%% Calling this function returns a listening socket that can then -%% be passed to accept/2 to accept connections. -%% -%% Available options may vary between transports. -%% -%% You can listen to a random port by setting the port option to 0. -%% It is then possible to retrieve this port number by calling -%% sockname/1 on the listening socket. If you are using Ranch's -%% listener API, then this port number can obtained through -%% ranch:get_port/1 instead. -callback listen(opts()) -> {ok, socket()} | {error, atom()}. - -%% Accept connections with the given listening socket. -callback accept(socket(), timeout()) -> {ok, socket()} | {error, closed | timeout | atom()}. - -%% Perform post-accept operations on the socket. -callback accept_ack(socket(), timeout()) -> ok. - -%% Experimental. Open a connection to the given host and port number. -callback connect(string(), inet:port_number(), opts()) -> {ok, socket()} | {error, atom()}. - -%% Experimental. Open a connection to the given host and port number -%% with a timeout. -callback connect(string(), inet:port_number(), opts(), timeout()) -> {ok, socket()} | {error, atom()}. - -%% Receive data from a socket in passive mode. -callback recv(socket(), non_neg_integer(), timeout()) -> {ok, any()} | {error, closed | timeout | atom()}. - -%% Send data on a socket. -callback send(socket(), iodata()) -> ok | {error, atom()}. - -%% Send a file on a socket. -callback sendfile(socket(), file:name() | file:fd()) -> {ok, non_neg_integer()} | {error, atom()}. - -%% Send part of a file on a socket. -callback sendfile(socket(), file:name() | file:fd(), non_neg_integer(), non_neg_integer()) -> {ok, non_neg_integer()} | {error, atom()}. - -%% Send part of a file on a socket. -callback sendfile(socket(), file:name() | file:fd(), non_neg_integer(), non_neg_integer(), sendfile_opts()) -> {ok, non_neg_integer()} | {error, atom()}. - -%% Set options on the given socket. -callback setopts(socket(), opts()) -> ok | {error, atom()}. - -%% Give control of the socket to a new process. -%% -%% Must be called from the process currently controlling the socket, -%% otherwise an {error, not_owner} tuple will be returned. -callback controlling_process(socket(), pid()) -> ok | {error, closed | not_owner | atom()}. - -%% Return the remote address and port of the connection. -callback peername(socket()) -> {ok, {inet:ip_address(), inet:port_number()}} | {error, atom()}. - -%% Return the local address and port of the connection. -callback sockname(socket()) -> {ok, {inet:ip_address(), inet:port_number()}} | {error, atom()}. - -%% Close the given socket. -callback close(socket()) -> ok. -%% @doc Send part of a file on a socket. -%% %% A fallback for transports that don't have a native sendfile implementation. %% Note that the ordering of arguments is different from file:sendfile/5 and %% that this function accepts either a raw file or a file name. -%% -%% @see file:sendfile/5 -spec sendfile(module(), socket(), file:filename_all() | file:fd(), non_neg_integer(), non_neg_integer(), sendfile_opts()) -> {ok, non_neg_integer()} | {error, atom()}. |