Linux and sendfile
Jeff Macdonald
jeff.macdonald at virtualbuilder.com
Tue Oct 29 17:52:03 EST 2002
out_fd is a socket
in_fd is a file
recent kernels. And you've guessed it, I want to use non-blocking mode
on the sockets (tcp).
basically I'm using sendfile to send the data portion of a SMTP session.
Since that may take a while, I'd like to do it in non-blocking mode. I
just read stevens APUE about O_NONBLOCK and for write I could get fewer
bytes then requested (page 365). So can I expect the same behavior from
sendfile?
On Tue, 2002-10-29 at 17:28, Kevin D. Clark wrote:
>
> Jeff Macdonald <jeff.macdonald at virtualbuilder.com> writes:
>
> > I'm hoping there are some fellow programmers here that have used the
> > sendfile system call. What I'm wondering is should I treat sendfile like
> > write when the out_fd is a socket. By that, I mean even if I specifiy N
> > count bytes, sendfile might only send < N bytes and if it does, I should
> > call sendfile again.
> >
> > Here's the prototype:
> > ssize_t sendfile(int out_fd, int in_fd, off_t *offset, size_t count);
>
> What type of fd's are these? Regular files? TCP sockets? UDP
> sockets? Something else?
>
> Are these fd's in blocking or non-blocking mode?
>
> What kernel are you running?
>
>
> Going under the assumption that these are TCP sockets running under a
> relatively recent kernel, *yes*, you definitely want to deal with the
> situation in which sendfile() returns something less than "count".
>
> Regards,
>
> --kevin
> --
> Kevin D. Clark / Cetacean Networks / Portsmouth, N.H. (USA)
> cetaceannetworks.com!kclark (GnuPG ID: B280F24E)
> alumni.unh.edu!kdc
More information about the gnhlug-discuss
mailing list