Manual Pages for UNIX Darwin command on man sendfile
MyWebUniversity

Manual Pages for UNIX Darwin command on man sendfile

SENDFILE(2) BSD System Calls Manual SENDFILE(2)

NAME

sseennddffiillee - send a file to a socket

SYNOPSIS

##iinncclluuddee <>

##iinncclluuddee <>

##iinncclluuddee <>

int sseennddffiillee(int fd, int s, offt offset, offt *len, struct sfhdtr *hdtr, int flags);

DESCRIPTION

The sseennddffiillee() system call sends a regular file specified by descriptor fd out a stream socket specified by descriptor s. The offset argument specifies where to begin in the file. Should offset fall beyond the end of file, the system will return success and report 0 bytes sent as described below.

The len argument is a value-result parameter, that specifies how many

bytes of the file should be sent and/or how many bytes have been sent. Initially the value pointed to by the len argument specifies how many bytes should be sent with 0 having the special meaning to send until the end of file has been reached. On return the value pointed to by the len argument indicates how many bytes have been sent. The len pointer may not be NULL. An optional header and/or trailer can be sent before and after the file data by specifying a pointer to a struct sfhdtr, which has the following structure: struct sfhdtr { struct iovec *headers; /* pointer to header iovecs */ int hdrcnt; /* number of header iovecs */ struct iovec *trailers; /* pointer to trailer iovecs */ int trlcnt; /* number of trailer iovecs */ };

The headers and trailers pointers, if non-NULL, point to arrays of struct

iovec structures. See the wwrriitteevv() system call for information on the iovec structure. The number of iovecs in these arrays is specified by hdrcnt and trlcnt. The flags parameter is reserved for future expansion and must be set to 0. Any other value will cause sseennddffiillee() to return EINVAL.

When using a socket marked for non-blocking I/O, sseennddffiillee() may send

fewer bytes than requested. In this case, the number of bytes success-

fully sent is returned in the via the len parameters and the error EAGAIN is returned.

When a signal causes sseennddffiillee() to return the error EINTR, the len argu-

ment may return 0 without necessarily meaning the end of file has been reached as the signal may have been caught before any data was sent. IIMMPPLLEEMMEENNTTAATTIIOONN NNOOTTEESS The Mac OS X implementation of sseennddffiillee() uses 64 bits types for size and offset parameters so there is no need for a 64 bits version sseennddffiillee6644() as found on some other operating systems.

RETURN VALUES

The sseennddffiillee() function returns the value 0 if successful; otherwise the

value -1 is returned and the global variable errno is set to indicate the

error. The number of bytes sent is returned via the parameter len. A value of 0 means the end of the file specified by descriptor fd has been reached or that the value passed in offset falls beyond the end of file. EERRRROORRSS

[EAGAIN] The socket is marked for non-blocking I/O and not all

data was sent due to the socket buffer being full. If specified, the number of bytes successfully sent will be returned in *len. [EBADF] The fd argument is not a valid file descriptor. [ENOTSUP] The fd argument does not refer to a regular file. [EBADF] The s argument is not a valid socket descriptor. [ENOTSOCK] The s argument does not refer stream oriented socket. [EFAULT] An invalid address was specified for an argument. [EINTR] A signal interrupted sseennddffiillee() before it could be

completed. If specified, the number of bytes success-

fully sent will be returned in *len. [EINVAL] The offset argument is negative. [EINVAL] The len argument is NULL. [EINVAL] The flags argument is not set to 0. [EIO] An error occurred while reading from fd. [ENOTCONN] The s argument points to an unconnected socket. [ENOTSOCK] The s argument is not a socket. [EOPNOTSUPP] The file system for descriptor fd does not support sseennddffiillee(). [EPIPE] The socket peer has closed the connection.

SEE ALSO

open(2), send(2), socket(2), writev(2) HISTORY The sseennddffiillee() system call first appeared in Darwin 9.0 (Mac OS X version 10.5) . AUTHORS This manual page is based on the FreeBSD version written by David G. Lawrence Mac OS X March 31, 2006 Mac OS X




Contact us      |      About us      |      Term of use      |       Copyright © 2000-2019 MyWebUniversity.com ™