On 06/16/2010 10:32 AM, Paul Steckler wrote: > I've written a wee Web server in OCaml that's compiled using the ocamlopt > from the > Fedora MinGW distribution of ocaml. I'm running the server in Windows 7. > > Sometimes after receiving several requests, the Unix.send call that sends a > response > back to a Web client just blocks.
Why is a blocking send() a problem? Isn't your application multithreaded? > The send buffer is pretty large (64k), and the data > to be sent is always much less than that. >From the manpage of send: "If space is not available at the sending socket to hold the message to be transmitted, and the socket file descriptor does not have O_NONBLOCK set, send() shall block until space is available." I think this occurs if the client has a slow/high latency connection, and it doesn't acknowledge the TCP packets in time. The packets you send are queued up in the kernel's TCP stack until they are acknowledged or time out. There is only a limited amount of data that can be buffered up like this per connection, when that is hit send() blocks. You could set the socket to nonblocking mode (and check with 'select' whether you can send), but according to the manual that doesn't work on the native windows port of OCaml. Best regards, --Edwin _______________________________________________ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs