sendfile() in FileChannelImpl.c

Greg Lewis glewis at
Sun Oct 18 20:43:46 PDT 2009

G'day Michael,

On Fri, Oct 16, 2009 at 04:55:08PM -0700, Michael Allman wrote:
> Can someone explain why we aren't using sendfile() in the transferTo0 call 
> for the case of a file transfer to a network socket in FileChannelImpl.c?
> Also, my understanding is that if this call cannot do a sendfile(), it 
> should return IOS_UNSUPPORTED_CASE.  This will tell the caller to do a 
> loop-based transfer (see, line 
> 531).

I think the reason is basically historical.  I don't recall there being
a fallback when we originally ported the NIO code, so sendfile() didn't
make sense since it only transferred to network sockets.

Before switching I'd want to see what sort of affect that had performance
wise on the case of transferring to a file descriptor.

Greg Lewis                          Email   : glewis at
Eyes Beyond                         Web     :
Information Technology              FreeBSD : glewis at

More information about the bsd-port-dev mailing list