httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marc Slemko <ma...@znep.com>
Subject sendfile API
Date Wed, 21 Oct 1998 05:45:05 GMT
Does anyone have any comments, positive or negative, on the following API
for a sendfile() implementation:

int sendfile(int fd, int s, off_t offset, size_t nbytes, struct sf_hdtr *hdtr,
        off_t *sbytes, int flags)

   fd is the file descriptor, s is the socket descriptor, nbytes is the number
of bytes to send (0 means send until EOF).
   If hdtr is non-NULL, headers and/or trailers will be sent. sf_hdtr has the
following structure:
/*
 * sendfile(2) header/trailer struct
 */
struct sf_hdtr {
        struct iovec *headers;  /* pointer to an array of header struct iovec's */
        int hdr_cnt;            /* number of header iovec's */
        struct iovec *trailers; /* pointer to an array of trailer struct iovec's */
        int trl_cnt;            /* number of trailer iovec's */
};

   *sbytes is an optional pointer for returning the number of bytes actually
sent on the socket. flags is currently unused, but may be used for future
auto-disconnect and un-bind() flags.
   sendfile(2) returns 0 for success. It returns -1 if an error occurs, with
errno set to the error and *sbytes set to the number of bytes that were sent
prior to the error.
   The only limitation this API appears to have is that nbytes is a size_t,
which is 32bits. Thus if you want to send less than the whole file, but more
than 4GB, you must do it in 4GB or less chunks via multiple calls. I don't
think this will be a serious problem, especially since most usage of
sendfile(2) will likely be with nbytes=0 (send until EOF).


Mime
View raw message