Behaviours: ranch_transport.
See also: gen_tcp.
TCP transport API.
Wrapper around gen_tcp implementing the Ranch transport API.accept/2 | Accept connections with the given listening socket. |
close/1 | Close the given socket. |
controlling_process/2 | Give control of the socket to a new process. |
listen/1 | Listen for connections on the given port number. |
messages/0 | Atoms used to identify messages in {active, once | true} mode. |
name/0 | Name of this transport, tcp. |
peername/1 | Return the remote address and port of the connection. |
recv/3 | Receive data from a socket in passive mode. |
send/2 | Send data on a socket. |
sendfile/2 | Send a file on a socket. |
setopts/2 | Set options on the given socket. |
sockname/1 | Return the local address and port of the connection. |
accept(LSocket::inet:socket(), Timeout::timeout()) -> {ok, inet:socket()} | {error, closed | timeout | atom()}
Accept connections with the given listening socket.
See also: gen_tcp:accept/2.
close(Socket::inet:socket()) -> ok
Close the given socket.
See also: gen_tcp:close/1.
controlling_process(Socket::inet:socket(), Pid::pid()) -> ok | {error, closed | not_owner | 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.See also: gen_tcp:controlling_process/2.
listen(Opts::[{backlog, non_neg_integer()} | {ip, inet:ip_address()} | {nodelay, boolean()} | {port, inet:port_number()}]) -> {ok, inet:socket()} | {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.
The available options are:See also: gen_tcp:listen/2.
messages() -> any()
Atoms used to identify messages in {active, once | true} mode.
name() -> any()
Name of this transport, tcp.
peername(Socket::inet:socket()) -> {ok, {inet:ip_address(), inet:port_number()}} | {error, atom()}
Return the remote address and port of the connection.
See also: inet:peername/1.
recv(Socket::inet:socket(), Length::non_neg_integer(), Timeout::timeout()) -> {ok, any()} | {error, closed | atom()}
Receive data from a socket in passive mode.
See also: gen_tcp:recv/3.
send(Socket::inet:socket(), Packet::iodata()) -> ok | {error, atom()}
Send data on a socket.
See also: gen_tcp:send/2.
sendfile(Socket::inet:socket(), Filename::file:name()) -> {ok, non_neg_integer()} | {error, atom()}
Send a file on a socket.
This is the optimal way to send files using TCP. It uses a syscall which means there is no context switch between opening the file and writing its contents on the socket.See also: file:sendfile/2.
setopts(Socket::inet:socket(), Opts::list()) -> ok | {error, atom()}
Set options on the given socket.
See also: inet:setopts/2.
sockname(Socket::inet:socket()) -> {ok, {inet:ip_address(), inet:port_number()}} | {error, atom()}
Return the local address and port of the connection.
See also: inet:sockname/1.
Generated by EDoc, Aug 3 2013, 11:17:12.