Linux and sendfile

Kevin D. Clark kclark at CetaceanNetworks.com
Tue Oct 29 17:28:19 EST 2002


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