caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Vincenzo Ciancia <vincenzo_yahoo_addressguard-gmane@yahoo.it>
To: caml-list@inria.fr
Subject: Re: Socket question
Date: Sun, 26 Mar 2006 13:00:02 +0200	[thread overview]
Message-ID: <e05s46$f0$1@sea.gmane.org> (raw)
In-Reply-To: <D5C8C04904809F45BEB9F23C05F60E752A162C@MOONRAKER.ad.parc.com>

Rong.Zhou@parc.com wrote:

> Can anyone tell me if there is a way in OCaml to *reliably* force a TCP
> socket to send out its buffered messages? I noticed that flushing the
> corresponding output channel of the socket does not *necessarily* cause
> the message to be sent. I know in C/C++ one can use the "TCP_NODELAY"
> socket option to solve this problem, but I couldn't find anything in
> OCaml that does this. I'd appreciate if someone can give me some
> pointers.

I don't have the time to deepen my knowledge of TCP sockets, but I think
that since they are file descriptors, you can (unsafely) cast a ocaml file
descriptor to an int in C land, and then set the option from C. 

Basically, you have to create an external function, written in C, similar to

value do_stuff_using_file_descr(value fd)
{
  int ifd=Int_val(fd);

  /* use ifd and set options as needed */

  return(Val_unit);
}

and then bind it in ocaml


external do_stuff_using_file_descr : Unix.file_descr -> unit =
"do_stuff_using_file_descr"

Find more information at

http://caml.inria.fr/pub/docs/manual-ocaml/manual032.html

Try that and see if it works. It should work under linux, don't know if on
windows or osx an ocaml file descriptor carries more information than just
the C file descriptor.

Vincenzo


-- 
Please note that I do not read the e-mail address used in the from field but
I read vincenzo_ml at yahoo dot it
Attenzione: non leggo l'indirizzo di posta usato nel campo from, ma leggo
vincenzo_ml at yahoo dot it


      reply	other threads:[~2006-03-26 10:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-24 21:42 Rong.Zhou
2006-03-26 11:00 ` Vincenzo Ciancia [this message]

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='e05s46$f0$1@sea.gmane.org' \
    --to=vincenzo_yahoo_addressguard-gmane@yahoo.it \
    --cc=caml-list@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).