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 nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 4A042BB83 for ; Thu, 24 Aug 2006 16:49:06 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.6/8.13.6) with ESMTP id k7OEluZo010021 for ; Thu, 24 Aug 2006 16:49:05 +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 QAA20307 for ; Thu, 24 Aug 2006 16:33:20 +0200 (MET DST) Received: from smtp103.sbc.mail.mud.yahoo.com (smtp103.sbc.mail.mud.yahoo.com [68.142.198.202]) by concorde.inria.fr (8.13.6/8.13.6) with SMTP id k7O8HoRN022949 for ; Thu, 24 Aug 2006 10:17:51 +0200 Received: (qmail 60472 invoked from network); 24 Aug 2006 08:17:50 -0000 Received: from unknown (HELO ?192.168.1.100?) (rftp@pacbell.net@69.230.202.10 with plain) by smtp103.sbc.mail.mud.yahoo.com with SMTP; 24 Aug 2006 08:17:49 -0000 Message-ID: <44ED60B9.7020805@rftp.com> Date: Thu, 24 Aug 2006 01:18:01 -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 nez-perce with ID 44EDBC1C.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 44ED60AE.00A 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 Sigh - this was first sent 15 hours ago, and a single "Mail Delivery Subsystem" notice about a non-fatal error came back at the 4-hour mark... but as it has never shown up, here it is again. -------- 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