<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html><body style='font-family: Verdana,Geneva,sans-serif'>
<p>Hi</p>
<p>I've been doing some tests using file:sendfile on FreeBSD 10 and it seems to be broken. It's unable to send files that are larger than the OS send buffer.</p>
<p>For example, if the buffer is 32KB, then only 48.996 bytes are sent to the client but from time to time it sends 130.708 bytes. It's always those numbers of bytes sent, 48.996 being the more popular one.</p>
<p>I discovered this when using Cowboy. I contacted Luic and we have been discussing some options, like the server could be closing the socket too soon. I created a simple test server to try things out where I for example delayed the closing of the socket well beyond the time it took the client to receive a full buffer. It had no effect, that is, the client just received its one and a half buffer and then waited until the server got to closing the socket. I tried both versions of sendfile.</p>
<p>If I use gen_tcp:send instead, the data is sent without any problems so I know the server works correctly.</p>
<p>Luic is planning on testing this in a few days but since I'm pretty sure (I can't rule out the possibility that I could be doing something wrong) the problem lies with Erlang itself I decided to post this here to get some further feedback.</p>
<p>I have a test server and client on github if someone cares to take a look: https://github.com/theom/eclm</p>
<p>Thanks,</p>
<p>Jens Páll</p>
<div> </div>
</body></html>