From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 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 EF90DBC29 for ; Thu, 24 Aug 2006 17:48:07 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id k7OFlu4T032486 for ; Thu, 24 Aug 2006 17:48:07 +0200 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id RAA27546 for ; Thu, 24 Aug 2006 17:34:15 +0200 (MET DST) Received: from smtp110.sbc.mail.mud.yahoo.com (smtp110.sbc.mail.mud.yahoo.com [68.142.198.209]) by nez-perce.inria.fr (8.13.6/8.13.6) with SMTP id k7NHZYHJ019844 for ; Wed, 23 Aug 2006 19:35:37 +0200 Received: (qmail 46013 invoked from network); 23 Aug 2006 17:35:34 -0000 Received: from unknown (HELO ?192.168.1.100?) (rftp@pacbell.net@69.230.202.10 with plain) by smtp110.sbc.mail.mud.yahoo.com with SMTP; 23 Aug 2006 17:35:34 -0000 Message-ID: <44EC91F0.3020103@rftp.com> Date: Wed, 23 Aug 2006 10:35:44 -0700 From: Robert Roessler User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a1) Gecko/20060818 SeaMonkey/1.5a MIME-Version: 1.0 To: Caml-list Subject: Re: [Caml-list] Re: Select on channels (again) References: <26EB47FDD566A7469FC862DAF373792F018CF5F4@kaiserslautern1.lmsintl.com> In-Reply-To: <26EB47FDD566A7469FC862DAF373792F018CF5F4@kaiserslautern1.lmsintl.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 44EDCA2C.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 44EC91E6.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; stub:01 buffer:01 otherlibs:01 unix:01 buffer:01 unix:01 ocaml:01 struct:01 loopback:01 getsockname:01 getsockname:01 runtime:01 assert:01 wrote:01 wrote:01 Christoph Bauer wrote: >>> ... >>> I did this, but on windows with two programs communicating >> over a pipe >>> this isn't enough. select on windows and on a pipe doesn't work. >>> Therefore I wrote a stub for PeekNamedPipe(): >> "Select on windows" certainly does work... and why not use a >> socket pair, just as one might on a *nix system? That way, >> it will work on both. > > Select doesn't work on window pipes. In retrospect sockects > would be the better choice. I stumbled in a strange dead lock > with theses pipes, because under windows the pipe buffer > is set to 1024 bytes (otherlibs/win32unix/pipe.c) and will then > block til the reader reads the contents. IMO this > value (SIZEBUF) should be zero to let the system choose the best > buffer size. [1] > >> And the fact that socketpair has been left out of the Windows >> version of the Unix module is not an impediment - it is easy >> to write a useful implementation in OCaml (I can supply one >> if needed). > > Please supply one. Here is what I use: open Unix module U2 = struct let socketpair af typ proto = let listener = socket af typ proto in let listener_addr = ADDR_INET(inet_addr_loopback, 0) in bind listener listener_addr; listen listener 1; let listener_name = getsockname listener in let connector = socket af typ proto in connect connector listener_name; let acceptor_full = accept listener in close listener; (* assert ((getsockname connector) = (snd acceptor_full)); *) (connector, (fst acceptor_full)) end ... and then select this socketpair or the one from the Unix module at runtime. Robert Roessler roessler@rftp.com http://www.rftp.com