caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Socket question
@ 2006-03-24 21:42 Rong.Zhou
  2006-03-26 11:00 ` Vincenzo Ciancia
  0 siblings, 1 reply; 2+ messages in thread
From: Rong.Zhou @ 2006-03-24 21:42 UTC (permalink / raw)
  To: caml-list

Hi,

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.

Thanks,
Rong


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Socket question
  2006-03-24 21:42 Socket question Rong.Zhou
@ 2006-03-26 11:00 ` Vincenzo Ciancia
  0 siblings, 0 replies; 2+ messages in thread
From: Vincenzo Ciancia @ 2006-03-26 11:00 UTC (permalink / raw)
  To: caml-list

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-03-26 10:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-24 21:42 Socket question Rong.Zhou
2006-03-26 11:00 ` Vincenzo Ciancia

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).