1 .\" Copyright (c) 2003, David G. Lawrence
2 .\" All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice unmodified, this list of conditions, and the following
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\" notice, this list of conditions and the following disclaimer in the
12 .\" documentation and/or other materials provided with the distribution.
14 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 .Nd send a file to a socket
39 .Fa "int fd" "int s" "off_t offset" "off_t *len"
40 .Fa "struct sf_hdtr *hdtr" "int flags"
46 sends a regular file specified by descriptor
48 out a stream socket specified by descriptor
53 argument specifies where to begin in the file.
56 fall beyond the end of file, the system will return
57 success and report 0 bytes sent as described below.
61 argument is a value-result parameter, that specifies how many bytes
62 of the file should be sent and/or how many bytes have been sent.
63 Initially the value pointed to by the
65 argument specifies how many bytes should be sent with 0 having the special
66 meaning to send until the end of file has been reached.
67 On return the value pointed to by the
69 argument indicates how many bytes have been sent, except when a header or
70 trailer is specified as shown below.
73 pointer may not be NULL.
75 An optional header and/or trailer can be sent before and after the file data by
76 specifying a pointer to a
77 .Vt "struct sf_hdtr" ,
78 which has the following structure:
80 .Bd -literal -offset indent -compact
82 struct iovec *headers; /* pointer to header iovecs */
83 int hdr_cnt; /* number of header iovecs */
84 struct iovec *trailers; /* pointer to trailer iovecs */
85 int trl_cnt; /* number of trailer iovecs */
100 system call for information on the iovec structure.
101 The number of iovecs in these
102 arrays is specified by
107 When a header or trailer is specified, the value of
109 argument indicates the maximum number of bytes in the header and/or file to be sent.
110 It does not control the trailer; if a trailer exists, all of it will be sent.
113 argument is 0, all of the header and/or file will be sent before the entire trailer is sent.
116 argument specifies the total number of bytes sent.
120 parameter is reserved for future expansion and must be set to 0. Any other value
126 When using a socket marked for non-blocking I/O,
128 may send fewer bytes than requested.
129 In this case, the number of bytes successfully
130 sent is returned in the via the
132 parameters and the error
142 argument may return 0 without necessarily meaning the end of file has been reached
143 as the signal may have been caught before any data was sent.
144 .Sh IMPLEMENTATION NOTES
149 uses 64 bits types for size and offset parameters so there is no need for
152 as found on some other operating systems.
156 The number of bytes sent is returned via the parameter
158 A value of 0 means the end of the file specified by descriptor
160 has been reached or that the value passed in
162 falls beyond the end of file.
166 The socket is marked for non-blocking I/O and not all data was sent due to
167 the socket buffer being full.
168 If specified, the number of bytes successfully sent will be returned in
174 is not a valid file descriptor.
179 does not refer to a regular file.
184 is not a valid socket descriptor.
189 does not refer stream oriented socket.
191 An invalid address was specified for an argument.
195 before it could be completed.
196 If specified, the number
197 of bytes successfully sent will be returned in
215 An error occurred while reading from
221 points to an unconnected socket.
228 The file system for descriptor
233 The socket peer has closed the connection.
245 Darwin 9.0 (Mac OS X version 10.5) .
247 This manual page is based on the FreeBSD version written by
248 .An David G. Lawrence Aq dg@dglawrence.com