diff options
author | Loïc Hoguin <[email protected]> | 2017-10-03 13:39:41 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2017-10-03 13:39:41 +0200 |
commit | b5d4cb91f80c833795a2d87050c3674bb7aecdc5 (patch) | |
tree | 62bf0ad8326006fcd3407fcb7c34c844c0dc0874 /docs/en/ranch/1.3/manual/ranch_transport | |
parent | 1f8d51dd2692fc3978080419987bbe4d49a41a90 (diff) | |
download | ninenines.eu-b5d4cb91f80c833795a2d87050c3674bb7aecdc5.tar.gz ninenines.eu-b5d4cb91f80c833795a2d87050c3674bb7aecdc5.tar.bz2 ninenines.eu-b5d4cb91f80c833795a2d87050c3674bb7aecdc5.zip |
Update Hugo, docs
Diffstat (limited to 'docs/en/ranch/1.3/manual/ranch_transport')
-rw-r--r-- | docs/en/ranch/1.3/manual/ranch_transport/index.html | 978 |
1 files changed, 489 insertions, 489 deletions
diff --git a/docs/en/ranch/1.3/manual/ranch_transport/index.html b/docs/en/ranch/1.3/manual/ranch_transport/index.html index aa57afd8..8840daad 100644 --- a/docs/en/ranch/1.3/manual/ranch_transport/index.html +++ b/docs/en/ranch/1.3/manual/ranch_transport/index.html @@ -7,7 +7,7 @@ <meta name="description" content=""> <meta name="author" content="Loïc Hoguin based on a design from (Soft10) Pol Cámara"> - <meta name="generator" content="Hugo 0.17" /> + <meta name="generator" content="Hugo 0.26" /> <title>Nine Nines: ranch_transport(3)</title> @@ -67,494 +67,494 @@ <h1 class="lined-header"><span>ranch_transport(3)</span></h1> -<div class="sect1">
-<h2 id="_name">Name</h2>
-<div class="sectionbody">
-<div class="paragraph"><p>ranch_transport - behaviour for transport modules</p></div>
-</div>
-</div>
-<div class="sect1">
-<h2 id="_description">Description</h2>
-<div class="sectionbody">
-<div class="paragraph"><p>The <code>ranch_transport</code> behaviour defines the interface used
-by Ranch transports.</p></div>
-</div>
-</div>
-<div class="sect1">
-<h2 id="_types">Types</h2>
-<div class="sectionbody">
-<div class="sect2">
-<h3 id="_sendfile_opts_chunk_size_non_neg_integer">sendfile_opts() = [{chunk_size, non_neg_integer()}]</h3>
-<div class="paragraph"><p>Options used by the sendfile function and callbacks.</p></div>
-<div class="paragraph"><p>Allows configuring the chunk size, in bytes. Defaults to 8191 bytes.</p></div>
-</div>
-</div>
-</div>
-<div class="sect1">
-<h2 id="_callbacks">Callbacks</h2>
-<div class="sectionbody">
-<div class="sect2">
-<h3 id="_accept_lsocket_timeout_8594_ok_csocket_error_closed_timeout_atom">accept(LSocket, Timeout) → {ok, CSocket} | {error, closed | timeout | atom()}</h3>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-LSocket = CSocket = any()
-</dt>
-<dd>
-<p>
-Listening socket.
-</p>
-</dd>
-<dt class="hdlist1">
-Timeout = timeout()
-</dt>
-<dd>
-<p>
-Accept timeout.
-</p>
-</dd>
-</dl></div>
-<div class="paragraph"><p>Accept a connection on the given listening socket.</p></div>
-<div class="paragraph"><p>The <code>accept_ack</code> callback will be used to initialize the socket
-after accepting the connection. This is most useful when the
-transport is not raw TCP, like with SSL for example.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_accept_ack_csocket_timeout_8594_ok">accept_ack(CSocket, Timeout) → ok</h3>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-CSocket = any()
-</dt>
-<dd>
-<p>
-Socket for this connection.
-</p>
-</dd>
-<dt class="hdlist1">
-Timeout = timeout()
-</dt>
-<dd>
-<p>
-Ack timeout.
-</p>
-</dd>
-</dl></div>
-<div class="paragraph"><p>Perform post-accept initialization of the connection.</p></div>
-<div class="paragraph"><p>This function will be called by connection processes
-before performing any socket operation. It allows
-transports that require extra initialization to perform
-their task and make the socket ready to use.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_close_socket_8594_ok">close(Socket) → ok</h3>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-Socket = any()
-</dt>
-<dd>
-<p>
-Socket opened with listen/1 or accept/2.
-</p>
-</dd>
-</dl></div>
-<div class="paragraph"><p>Close the given socket.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_controlling_process_socket_pid_8594_ok_error_closed_not_owner_atom">controlling_process(Socket, Pid) → ok | {error, closed | not_owner | atom()}</h3>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-Socket = any()
-</dt>
-<dd>
-<p>
-Socket opened with listen/1 or accept/2.
-</p>
-</dd>
-<dt class="hdlist1">
-Pid = pid()
-</dt>
-<dd>
-<p>
-Pid of the new owner of the socket.
-</p>
-</dd>
-</dl></div>
-<div class="paragraph"><p>Change the controlling process for the given socket.</p></div>
-<div class="paragraph"><p>The controlling process is the process that is allowed to
-perform operations on the socket, and that will receive
-messages from the socket when active mode is used. When
-the controlling process dies, the socket is closed.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_listen_transopts_8594_ok_lsocket_error_atom">listen(TransOpts) → {ok, LSocket} | {error, atom()}</h3>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-TransOpts = any()
-</dt>
-<dd>
-<p>
-Transport options.
-</p>
-</dd>
-<dt class="hdlist1">
-LSocket = any()
-</dt>
-<dd>
-<p>
-Listening socket.
-</p>
-</dd>
-</dl></div>
-<div class="paragraph"><p>Listen for connections on the given port.</p></div>
-<div class="paragraph"><p>The port is given as part of the transport options under
-the key <code>port</code>. Any other option is transport dependent.</p></div>
-<div class="paragraph"><p>The socket returned by this call can then be used to
-accept connections. It is not possible to send or receive
-data from the listening socket.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_messages_8594_ok_closed_error">messages() → {OK, Closed, Error}</h3>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-OK = Closed = Error = atom()
-</dt>
-<dd>
-<p>
-Tuple names.
-</p>
-</dd>
-</dl></div>
-<div class="paragraph"><p>Return the atoms used to identify messages sent in active mode.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_name_8594_name">name() → Name</h3>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-Name = atom()
-</dt>
-<dd>
-<p>
-Transport module name.
-</p>
-</dd>
-</dl></div>
-<div class="paragraph"><p>Return the name of the transport.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_peername_csocket_8594_ok_ip_port_error_atom">peername(CSocket) → {ok, {IP, Port}} | {error, atom()}</h3>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-CSocket = any()
-</dt>
-<dd>
-<p>
-Socket for this connection.
-</p>
-</dd>
-<dt class="hdlist1">
-IP = inet:ip_address()
-</dt>
-<dd>
-<p>
-IP of the remote endpoint.
-</p>
-</dd>
-<dt class="hdlist1">
-Port = inet:port_number()
-</dt>
-<dd>
-<p>
-Port of the remote endpoint.
-</p>
-</dd>
-</dl></div>
-<div class="paragraph"><p>Return the IP and port of the remote endpoint.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_recv_csocket_length_timeout_8594_ok_packet_error_closed_timeout_atom">recv(CSocket, Length, Timeout) → {ok, Packet} | {error, closed | timeout | atom()}</h3>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-CSocket = any()
-</dt>
-<dd>
-<p>
-Socket for this connection.
-</p>
-</dd>
-<dt class="hdlist1">
-Length = non_neg_integer()
-</dt>
-<dd>
-<p>
-Requested length.
-</p>
-</dd>
-<dt class="hdlist1">
-Timeout = timeout()
-</dt>
-<dd>
-<p>
-Receive timeout.
-</p>
-</dd>
-<dt class="hdlist1">
-Packet = iodata() | any()
-</dt>
-<dd>
-<p>
-Data received.
-</p>
-</dd>
-</dl></div>
-<div class="paragraph"><p>Receive data from the given socket when in passive mode.</p></div>
-<div class="paragraph"><p>Trying to receive data from a socket that is in active mode
-will return an error.</p></div>
-<div class="paragraph"><p>A length of 0 will return any data available on the socket.</p></div>
-<div class="paragraph"><p>While it is possible to use the timeout value <code>infinity</code>,
-this is highly discouraged as this could cause your process
-to get stuck waiting for data that will never come. This may
-happen when a socket becomes half-open due to a crash of the
-remote endpoint. Wi-Fi going down is another common culprit
-of this issue.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_send_csocket_packet_8594_ok_error_atom">send(CSocket, Packet) → ok | {error, atom()}</h3>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-CSocket = any()
-</dt>
-<dd>
-<p>
-Socket for this connection.
-</p>
-</dd>
-<dt class="hdlist1">
-Packet = iodata()
-</dt>
-<dd>
-<p>
-Data to be sent.
-</p>
-</dd>
-</dl></div>
-<div class="paragraph"><p>Send data to the given socket.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_sendfile_csocket_file_8594_sendfile_csocket_file_0_0">sendfile(CSocket, File) → sendfile(CSocket, File, 0, 0, [])</h3>
-<div class="paragraph"><p>Alias of <code>ranch_transport:sendfile/5</code>.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_sendfile_csocket_file_offset_bytes_8594_sendfile_csocket_file_offset_bytes">sendfile(CSocket, File, Offset, Bytes) → sendfile(CSocket, File, Offset, Bytes, [])</h3>
-<div class="paragraph"><p>Alias of <code>ranch_transport:sendfile/5</code>.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_sendfile_csocket_file_offset_bytes_sfopts_8594_ok_sentbytes_error_atom">sendfile(CSocket, File, Offset, Bytes, SfOpts) → {ok, SentBytes} | {error, atom()}</h3>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-CSocket = any()
-</dt>
-<dd>
-<p>
-Socket for this connection.
-</p>
-</dd>
-<dt class="hdlist1">
-File = file:filename_all() | file:fd()
-</dt>
-<dd>
-<p>
-Filename or file descriptor for the file to be sent.
-</p>
-</dd>
-<dt class="hdlist1">
-Offset = non_neg_integer()
-</dt>
-<dd>
-<p>
-Begin sending at this position in the file.
-</p>
-</dd>
-<dt class="hdlist1">
-Bytes = non_neg_integer()
-</dt>
-<dd>
-<p>
-Send this many bytes.
-</p>
-</dd>
-<dt class="hdlist1">
-SentBytes = non_neg_integer()
-</dt>
-<dd>
-<p>
-This many bytes were sent.
-</p>
-</dd>
-<dt class="hdlist1">
-SfOpts = sendfile_opts()
-</dt>
-<dd>
-<p>
-Sendfile options.
-</p>
-</dd>
-</dl></div>
-<div class="paragraph"><p>Send data from a file to the given socket.</p></div>
-<div class="paragraph"><p>The file may be sent full or in parts, and may be specified
-by its filename or by an already open file descriptor.</p></div>
-<div class="paragraph"><p>Transports that manipulate TCP directly may use the
-<code>file:sendfile/{2,4,5}</code> function, which calls the sendfile
-syscall where applicable (on Linux, for example). Other
-transports can use the <code>sendfile/6</code> function exported from
-this module.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_setopts_csocket_sockopts_8594_ok_error_atom">setopts(CSocket, SockOpts) → ok | {error, atom()}</h3>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-CSocket = any()
-</dt>
-<dd>
-<p>
-Socket for this connection.
-</p>
-</dd>
-<dt class="hdlist1">
-SockOpts = any()
-</dt>
-<dd>
-<p>
-Socket options.
-</p>
-</dd>
-</dl></div>
-<div class="paragraph"><p>Change options for the given socket.</p></div>
-<div class="paragraph"><p>This is mainly useful for switching to active or passive mode
-or to set protocol-specific options.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_shutdown_csocket_how_8594_ok_error_atom">shutdown(CSocket, How) → ok | {error, atom()}</h3>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-CSocket = any()
-</dt>
-<dd>
-<p>
-Socket for this connection.
-</p>
-</dd>
-<dt class="hdlist1">
-How = read | write | read_write
-</dt>
-<dd>
-<p>
-Which side(s) of the socket to close.
-</p>
-</dd>
-</dl></div>
-<div class="paragraph"><p>Immediately close the socket in one or two directions.</p></div>
-</div>
-<div class="sect2">
-<h3 id="_sockname_socket_8594_ok_ip_port_error_atom">sockname(Socket) → {ok, {IP, Port}} | {error, atom()}</h3>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-Socket = any()
-</dt>
-<dd>
-<p>
-Socket opened with listen/1 or accept/2.
-</p>
-</dd>
-<dt class="hdlist1">
-IP = inet:ip_address()
-</dt>
-<dd>
-<p>
-IP of the local endpoint.
-</p>
-</dd>
-<dt class="hdlist1">
-Port = inet:port_number()
-</dt>
-<dd>
-<p>
-Port of the local endpoint.
-</p>
-</dd>
-</dl></div>
-<div class="paragraph"><p>Return the IP and port of the local endpoint.</p></div>
-</div>
-</div>
-</div>
-<div class="sect1">
-<h2 id="_exports">Exports</h2>
-<div class="sectionbody">
-<div class="sect2">
-<h3 id="_sendfile_transport_csocket_file_offset_bytes_sfopts_8594_ok_sentbytes_error_atom">sendfile(Transport, CSocket, File, Offset, Bytes, SfOpts) → {ok, SentBytes} | {error, atom()}</h3>
-<div class="dlist"><dl>
-<dt class="hdlist1">
-Transport = module()
-</dt>
-<dd>
-<p>
-Transport module for this socket.
-</p>
-</dd>
-<dt class="hdlist1">
-CSocket = any()
-</dt>
-<dd>
-<p>
-Socket for this connection.
-</p>
-</dd>
-<dt class="hdlist1">
-File = file:filename_all() | file:fd()
-</dt>
-<dd>
-<p>
-Filename or file descriptor for the file to be sent.
-</p>
-</dd>
-<dt class="hdlist1">
-Offset = non_neg_integer()
-</dt>
-<dd>
-<p>
-Begin sending at this position in the file.
-</p>
-</dd>
-<dt class="hdlist1">
-Bytes = non_neg_integer()
-</dt>
-<dd>
-<p>
-Send this many bytes.
-</p>
-</dd>
-<dt class="hdlist1">
-SentBytes = non_neg_integer()
-</dt>
-<dd>
-<p>
-This many bytes were sent.
-</p>
-</dd>
-<dt class="hdlist1">
-SfOpts = sendfile_opts()
-</dt>
-<dd>
-<p>
-Sendfile options.
-</p>
-</dd>
-</dl></div>
-<div class="paragraph"><p>Send data from a file to the given socket.</p></div>
-<div class="paragraph"><p>This function emulates the function <code>file:sendfile/{2,4,5}</code>
-and may be used when transports are not manipulating TCP
-directly.</p></div>
-</div>
-</div>
-</div>
+<div class="sect1"> +<h2 id="_name">Name</h2> +<div class="sectionbody"> +<div class="paragraph"><p>ranch_transport - behaviour for transport modules</p></div> +</div> +</div> +<div class="sect1"> +<h2 id="_description">Description</h2> +<div class="sectionbody"> +<div class="paragraph"><p>The <code>ranch_transport</code> behaviour defines the interface used +by Ranch transports.</p></div> +</div> +</div> +<div class="sect1"> +<h2 id="_types">Types</h2> +<div class="sectionbody"> +<div class="sect2"> +<h3 id="_sendfile_opts_chunk_size_non_neg_integer">sendfile_opts() = [{chunk_size, non_neg_integer()}]</h3> +<div class="paragraph"><p>Options used by the sendfile function and callbacks.</p></div> +<div class="paragraph"><p>Allows configuring the chunk size, in bytes. Defaults to 8191 bytes.</p></div> +</div> +</div> +</div> +<div class="sect1"> +<h2 id="_callbacks">Callbacks</h2> +<div class="sectionbody"> +<div class="sect2"> +<h3 id="_accept_lsocket_timeout_8594_ok_csocket_error_closed_timeout_atom">accept(LSocket, Timeout) → {ok, CSocket} | {error, closed | timeout | atom()}</h3> +<div class="dlist"><dl> +<dt class="hdlist1"> +LSocket = CSocket = any() +</dt> +<dd> +<p> +Listening socket. +</p> +</dd> +<dt class="hdlist1"> +Timeout = timeout() +</dt> +<dd> +<p> +Accept timeout. +</p> +</dd> +</dl></div> +<div class="paragraph"><p>Accept a connection on the given listening socket.</p></div> +<div class="paragraph"><p>The <code>accept_ack</code> callback will be used to initialize the socket +after accepting the connection. This is most useful when the +transport is not raw TCP, like with SSL for example.</p></div> +</div> +<div class="sect2"> +<h3 id="_accept_ack_csocket_timeout_8594_ok">accept_ack(CSocket, Timeout) → ok</h3> +<div class="dlist"><dl> +<dt class="hdlist1"> +CSocket = any() +</dt> +<dd> +<p> +Socket for this connection. +</p> +</dd> +<dt class="hdlist1"> +Timeout = timeout() +</dt> +<dd> +<p> +Ack timeout. +</p> +</dd> +</dl></div> +<div class="paragraph"><p>Perform post-accept initialization of the connection.</p></div> +<div class="paragraph"><p>This function will be called by connection processes +before performing any socket operation. It allows +transports that require extra initialization to perform +their task and make the socket ready to use.</p></div> +</div> +<div class="sect2"> +<h3 id="_close_socket_8594_ok">close(Socket) → ok</h3> +<div class="dlist"><dl> +<dt class="hdlist1"> +Socket = any() +</dt> +<dd> +<p> +Socket opened with listen/1 or accept/2. +</p> +</dd> +</dl></div> +<div class="paragraph"><p>Close the given socket.</p></div> +</div> +<div class="sect2"> +<h3 id="_controlling_process_socket_pid_8594_ok_error_closed_not_owner_atom">controlling_process(Socket, Pid) → ok | {error, closed | not_owner | atom()}</h3> +<div class="dlist"><dl> +<dt class="hdlist1"> +Socket = any() +</dt> +<dd> +<p> +Socket opened with listen/1 or accept/2. +</p> +</dd> +<dt class="hdlist1"> +Pid = pid() +</dt> +<dd> +<p> +Pid of the new owner of the socket. +</p> +</dd> +</dl></div> +<div class="paragraph"><p>Change the controlling process for the given socket.</p></div> +<div class="paragraph"><p>The controlling process is the process that is allowed to +perform operations on the socket, and that will receive +messages from the socket when active mode is used. When +the controlling process dies, the socket is closed.</p></div> +</div> +<div class="sect2"> +<h3 id="_listen_transopts_8594_ok_lsocket_error_atom">listen(TransOpts) → {ok, LSocket} | {error, atom()}</h3> +<div class="dlist"><dl> +<dt class="hdlist1"> +TransOpts = any() +</dt> +<dd> +<p> +Transport options. +</p> +</dd> +<dt class="hdlist1"> +LSocket = any() +</dt> +<dd> +<p> +Listening socket. +</p> +</dd> +</dl></div> +<div class="paragraph"><p>Listen for connections on the given port.</p></div> +<div class="paragraph"><p>The port is given as part of the transport options under +the key <code>port</code>. Any other option is transport dependent.</p></div> +<div class="paragraph"><p>The socket returned by this call can then be used to +accept connections. It is not possible to send or receive +data from the listening socket.</p></div> +</div> +<div class="sect2"> +<h3 id="_messages_8594_ok_closed_error">messages() → {OK, Closed, Error}</h3> +<div class="dlist"><dl> +<dt class="hdlist1"> +OK = Closed = Error = atom() +</dt> +<dd> +<p> +Tuple names. +</p> +</dd> +</dl></div> +<div class="paragraph"><p>Return the atoms used to identify messages sent in active mode.</p></div> +</div> +<div class="sect2"> +<h3 id="_name_8594_name">name() → Name</h3> +<div class="dlist"><dl> +<dt class="hdlist1"> +Name = atom() +</dt> +<dd> +<p> +Transport module name. +</p> +</dd> +</dl></div> +<div class="paragraph"><p>Return the name of the transport.</p></div> +</div> +<div class="sect2"> +<h3 id="_peername_csocket_8594_ok_ip_port_error_atom">peername(CSocket) → {ok, {IP, Port}} | {error, atom()}</h3> +<div class="dlist"><dl> +<dt class="hdlist1"> +CSocket = any() +</dt> +<dd> +<p> +Socket for this connection. +</p> +</dd> +<dt class="hdlist1"> +IP = inet:ip_address() +</dt> +<dd> +<p> +IP of the remote endpoint. +</p> +</dd> +<dt class="hdlist1"> +Port = inet:port_number() +</dt> +<dd> +<p> +Port of the remote endpoint. +</p> +</dd> +</dl></div> +<div class="paragraph"><p>Return the IP and port of the remote endpoint.</p></div> +</div> +<div class="sect2"> +<h3 id="_recv_csocket_length_timeout_8594_ok_packet_error_closed_timeout_atom">recv(CSocket, Length, Timeout) → {ok, Packet} | {error, closed | timeout | atom()}</h3> +<div class="dlist"><dl> +<dt class="hdlist1"> +CSocket = any() +</dt> +<dd> +<p> +Socket for this connection. +</p> +</dd> +<dt class="hdlist1"> +Length = non_neg_integer() +</dt> +<dd> +<p> +Requested length. +</p> +</dd> +<dt class="hdlist1"> +Timeout = timeout() +</dt> +<dd> +<p> +Receive timeout. +</p> +</dd> +<dt class="hdlist1"> +Packet = iodata() | any() +</dt> +<dd> +<p> +Data received. +</p> +</dd> +</dl></div> +<div class="paragraph"><p>Receive data from the given socket when in passive mode.</p></div> +<div class="paragraph"><p>Trying to receive data from a socket that is in active mode +will return an error.</p></div> +<div class="paragraph"><p>A length of 0 will return any data available on the socket.</p></div> +<div class="paragraph"><p>While it is possible to use the timeout value <code>infinity</code>, +this is highly discouraged as this could cause your process +to get stuck waiting for data that will never come. This may +happen when a socket becomes half-open due to a crash of the +remote endpoint. Wi-Fi going down is another common culprit +of this issue.</p></div> +</div> +<div class="sect2"> +<h3 id="_send_csocket_packet_8594_ok_error_atom">send(CSocket, Packet) → ok | {error, atom()}</h3> +<div class="dlist"><dl> +<dt class="hdlist1"> +CSocket = any() +</dt> +<dd> +<p> +Socket for this connection. +</p> +</dd> +<dt class="hdlist1"> +Packet = iodata() +</dt> +<dd> +<p> +Data to be sent. +</p> +</dd> +</dl></div> +<div class="paragraph"><p>Send data to the given socket.</p></div> +</div> +<div class="sect2"> +<h3 id="_sendfile_csocket_file_8594_sendfile_csocket_file_0_0">sendfile(CSocket, File) → sendfile(CSocket, File, 0, 0, [])</h3> +<div class="paragraph"><p>Alias of <code>ranch_transport:sendfile/5</code>.</p></div> +</div> +<div class="sect2"> +<h3 id="_sendfile_csocket_file_offset_bytes_8594_sendfile_csocket_file_offset_bytes">sendfile(CSocket, File, Offset, Bytes) → sendfile(CSocket, File, Offset, Bytes, [])</h3> +<div class="paragraph"><p>Alias of <code>ranch_transport:sendfile/5</code>.</p></div> +</div> +<div class="sect2"> +<h3 id="_sendfile_csocket_file_offset_bytes_sfopts_8594_ok_sentbytes_error_atom">sendfile(CSocket, File, Offset, Bytes, SfOpts) → {ok, SentBytes} | {error, atom()}</h3> +<div class="dlist"><dl> +<dt class="hdlist1"> +CSocket = any() +</dt> +<dd> +<p> +Socket for this connection. +</p> +</dd> +<dt class="hdlist1"> +File = file:filename_all() | file:fd() +</dt> +<dd> +<p> +Filename or file descriptor for the file to be sent. +</p> +</dd> +<dt class="hdlist1"> +Offset = non_neg_integer() +</dt> +<dd> +<p> +Begin sending at this position in the file. +</p> +</dd> +<dt class="hdlist1"> +Bytes = non_neg_integer() +</dt> +<dd> +<p> +Send this many bytes. +</p> +</dd> +<dt class="hdlist1"> +SentBytes = non_neg_integer() +</dt> +<dd> +<p> +This many bytes were sent. +</p> +</dd> +<dt class="hdlist1"> +SfOpts = sendfile_opts() +</dt> +<dd> +<p> +Sendfile options. +</p> +</dd> +</dl></div> +<div class="paragraph"><p>Send data from a file to the given socket.</p></div> +<div class="paragraph"><p>The file may be sent full or in parts, and may be specified +by its filename or by an already open file descriptor.</p></div> +<div class="paragraph"><p>Transports that manipulate TCP directly may use the +<code>file:sendfile/{2,4,5}</code> function, which calls the sendfile +syscall where applicable (on Linux, for example). Other +transports can use the <code>sendfile/6</code> function exported from +this module.</p></div> +</div> +<div class="sect2"> +<h3 id="_setopts_csocket_sockopts_8594_ok_error_atom">setopts(CSocket, SockOpts) → ok | {error, atom()}</h3> +<div class="dlist"><dl> +<dt class="hdlist1"> +CSocket = any() +</dt> +<dd> +<p> +Socket for this connection. +</p> +</dd> +<dt class="hdlist1"> +SockOpts = any() +</dt> +<dd> +<p> +Socket options. +</p> +</dd> +</dl></div> +<div class="paragraph"><p>Change options for the given socket.</p></div> +<div class="paragraph"><p>This is mainly useful for switching to active or passive mode +or to set protocol-specific options.</p></div> +</div> +<div class="sect2"> +<h3 id="_shutdown_csocket_how_8594_ok_error_atom">shutdown(CSocket, How) → ok | {error, atom()}</h3> +<div class="dlist"><dl> +<dt class="hdlist1"> +CSocket = any() +</dt> +<dd> +<p> +Socket for this connection. +</p> +</dd> +<dt class="hdlist1"> +How = read | write | read_write +</dt> +<dd> +<p> +Which side(s) of the socket to close. +</p> +</dd> +</dl></div> +<div class="paragraph"><p>Immediately close the socket in one or two directions.</p></div> +</div> +<div class="sect2"> +<h3 id="_sockname_socket_8594_ok_ip_port_error_atom">sockname(Socket) → {ok, {IP, Port}} | {error, atom()}</h3> +<div class="dlist"><dl> +<dt class="hdlist1"> +Socket = any() +</dt> +<dd> +<p> +Socket opened with listen/1 or accept/2. +</p> +</dd> +<dt class="hdlist1"> +IP = inet:ip_address() +</dt> +<dd> +<p> +IP of the local endpoint. +</p> +</dd> +<dt class="hdlist1"> +Port = inet:port_number() +</dt> +<dd> +<p> +Port of the local endpoint. +</p> +</dd> +</dl></div> +<div class="paragraph"><p>Return the IP and port of the local endpoint.</p></div> +</div> +</div> +</div> +<div class="sect1"> +<h2 id="_exports">Exports</h2> +<div class="sectionbody"> +<div class="sect2"> +<h3 id="_sendfile_transport_csocket_file_offset_bytes_sfopts_8594_ok_sentbytes_error_atom">sendfile(Transport, CSocket, File, Offset, Bytes, SfOpts) → {ok, SentBytes} | {error, atom()}</h3> +<div class="dlist"><dl> +<dt class="hdlist1"> +Transport = module() +</dt> +<dd> +<p> +Transport module for this socket. +</p> +</dd> +<dt class="hdlist1"> +CSocket = any() +</dt> +<dd> +<p> +Socket for this connection. +</p> +</dd> +<dt class="hdlist1"> +File = file:filename_all() | file:fd() +</dt> +<dd> +<p> +Filename or file descriptor for the file to be sent. +</p> +</dd> +<dt class="hdlist1"> +Offset = non_neg_integer() +</dt> +<dd> +<p> +Begin sending at this position in the file. +</p> +</dd> +<dt class="hdlist1"> +Bytes = non_neg_integer() +</dt> +<dd> +<p> +Send this many bytes. +</p> +</dd> +<dt class="hdlist1"> +SentBytes = non_neg_integer() +</dt> +<dd> +<p> +This many bytes were sent. +</p> +</dd> +<dt class="hdlist1"> +SfOpts = sendfile_opts() +</dt> +<dd> +<p> +Sendfile options. +</p> +</dd> +</dl></div> +<div class="paragraph"><p>Send data from a file to the given socket.</p></div> +<div class="paragraph"><p>This function emulates the function <code>file:sendfile/{2,4,5}</code> +and may be used when transports are not manipulating TCP +directly.</p></div> +</div> +</div> +</div> |