caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Török Edwin" <edwintorok@gmail.com>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Unix.send blocks
Date: Wed, 16 Jun 2010 12:08:50 +0300	[thread overview]
Message-ID: <4C1894A2.3020805@gmail.com> (raw)
In-Reply-To: <2EB36A07AAE8C44BBB1986425E7A22D0127E01BE32@atp-mbx1.in.nicta.com.au>

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


  parent reply	other threads:[~2010-06-16  9:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-16  7:32 Paul Steckler
2010-06-16  8:55 ` Sylvain Le Gall
2010-06-16  9:11   ` [Caml-list] " Christoph Bauer
2010-06-16  9:46     ` Sylvain Le Gall
2010-06-16  9:08 ` Török Edwin [this message]
2010-06-16  9:49   ` Sylvain Le Gall
2010-06-16 10:08 ` [Caml-list] " David Allsopp

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4C1894A2.3020805@gmail.com \
    --to=edwintorok@gmail.com \
    --cc=caml-list@yquem.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).