From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 8A1CCBBBB for ; Sun, 26 Mar 2006 12:58:41 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id k2QAwe9O004455 for ; Sun, 26 Mar 2006 12:58:40 +0200 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id MAA24655 for ; Sun, 26 Mar 2006 12:58:40 +0200 (MET DST) Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id k2QAwdsE004448 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO) for ; Sun, 26 Mar 2006 12:58:39 +0200 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1FNSwv-0007IX-O9 for caml-list@inria.fr; Sun, 26 Mar 2006 12:58:22 +0200 Received: from host213-195.pool8255.interbusiness.it ([82.55.195.213]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 26 Mar 2006 12:58:21 +0200 Received: from vincenzo_yahoo_addressguard-gmane by host213-195.pool8255.interbusiness.it with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 26 Mar 2006 12:58:21 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: caml-list@inria.fr From: Vincenzo Ciancia Subject: Re: Socket question Date: Sun, 26 Mar 2006 13:00:02 +0200 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: host213-195.pool8255.interbusiness.it User-Agent: KNode/0.10.1 Sender: news X-Miltered: at concorde with ID 442673E0.002 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 442673DF.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; ocaml:01 buffered:01 ocaml:01 pointers:01 sockets:01 descriptors:01 val:01 val:01 unix:01 osx:01 attenzione:98 l'indirizzo:98 posta:98 nel:98 campo:98 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 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