[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2006-03-26 (10:58) |
From: | Vincenzo Ciancia <vincenzo_yahoo_addressguard-gmane@y...> |
Subject: | Re: Socket question |
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