summaryrefslogtreecommitdiff
path: root/lib/stdlib/test/shell_docs_SUITE_data/kernel_file_sendfile_5_func.txt
blob: 991f012cb5f0fbde55d94bd31ee5648d700eb98d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41

  -spec sendfile(RawFile, Socket, Offset, Bytes, Opts) ->
                    {ok, non_neg_integer()} |
                    {error, inet:posix() | closed | badarg | not_owner}
                    when
                        RawFile :: fd(),
                        Socket ::
                            inet:socket() |
                            socket:socket() |
                            fun((iolist()) ->
                                    ok | {error, inet:posix() | closed}),
                        Offset :: non_neg_integer(),
                        Bytes :: non_neg_integer(),
                        Opts :: [sendfile_option()].

Since:
  OTP R15B

  Types:
    -type sendfile_option() ::
          {chunk_size, non_neg_integer()} | {use_threads, boolean()}.

  Sends Bytes from the file referenced by RawFile beginning at 
  Offset to Socket. Returns {ok, BytesSent} if successful,
  otherwise {error, Reason}. If Bytes is set to 0 all data
  after the specified Offset is sent.

  The file used must be opened using the raw flag, and the process
  calling sendfile must be the controlling process of the socket.
  See gen_tcp:controlling_process/2 or module socket's level 
  otp socket option controlling_process.

  If the OS used does not support non-blocking sendfile, an Erlang
  fallback using read/2 and gen_tcp:send/2 is used.

  The option list can contain the following options:

  chunk_size:
    The chunk size used by the Erlang fallback to send data. If
    using the fallback, set this to a value that comfortably fits
    in the systems memory. Default is 20 MB.