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 CF107BB9C for ; Wed, 16 Nov 2005 14:20:52 +0100 (CET) Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.191]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id jAGDKqOG031520 for ; Wed, 16 Nov 2005 14:20:52 +0100 Received: from [212.227.126.160] (helo=mrelayng.kundenserver.de) by moutng.kundenserver.de with esmtp (Exim 3.35 #1) id 1EcNDU-0002B7-00; Wed, 16 Nov 2005 14:20:48 +0100 Received: from [84.58.131.203] (helo=gate.lan.gerd-stolpmann.de) by mrelayng.kundenserver.de with asmtp (Exim 3.35 #1) id 1EcNDU-0001fo-00; Wed, 16 Nov 2005 14:20:48 +0100 Received: from gps.dynxs.de (localhost [127.0.0.1]) by gate.lan.gerd-stolpmann.de (Postfix) with ESMTP id 6B456C095; Wed, 16 Nov 2005 14:20:47 +0100 (CET) Received: from 192.168.1.2 (proxying for 194.127.8.19) (SquirrelMail authenticated user gerd) by gps.dynxs.de with HTTP; Wed, 16 Nov 2005 14:20:47 +0100 (CET) Message-ID: <2367.192.168.1.2.1132147247.squirrel@gps.dynxs.de> In-Reply-To: <200511161302.jAGD1rWV009969@mac.com> References: <200511161302.jAGD1rWV009969@mac.com> Date: Wed, 16 Nov 2005 14:20:47 +0100 (CET) Subject: Re: [Caml-list] Problem with network example of Ocaml book From: "Gerd Stolpmann" To: anobject@mac.com Cc: caml-list@yquem.inria.fr User-Agent: SquirrelMail/1.4.4 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Provags-ID: kundenserver.de abuse@kundenserver.de auth:a6865a839c0178d9aa0ce41878507ea2 X-Miltered: at concorde with ID 437B3234.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 ocaml:01 gerd:01 stolpmann:01 getsockname:01 gerd:01 hash:01 ocaml:01 cygwin:01 einval:01 gethostname:01 getsockname:01 failwith:01 val:01 abstr:01 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 The socket is not bound, so getsockname cannot return anything. After Unix.bind or Unix.connect the socket will have a "name", i.e. be bound to a port. Gerd Harald Schmidt said: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Hi all, > > I worked through the network example (page 629) of the the Ocaml book, = and > don't know what's going wrong with the last statement. I am using Ocaml > under cygwin / WinXP. > > I know, EINVAL means invalid argument, but as far as I read s_descr is > used > as an abstract file descriptor. Is this wrong? > > > - > -----------------------------------------------------------------------= ----- > - ------------------------------------------------- > let my_name =3D Unix.gethostname ();; > let my_entry_byname =3D Unix.gethostbyname my_name;; > let my_addr =3D my_entry_byname.Unix.h_addr_list.(0);; > let my_entry_byaddr =3D Unix.gethostbyaddr my_addr;; > let my_full_name =3D my_entry_byaddr.Unix.h_name;; > let s_descr =3D Unix.socket Unix.PF_INET Unix.SOCK_STREAM 0;; > let (addr_in, p_num) =3D > match Unix.getsockname s_descr with > Unix.ADDR_INET (a,n) -> (a,n) > | _ -> failwith "not INET";; > > # val my_entry_byname : Unix.host_entry =3D > {Unix.h_name =3D "CNCHZUR2497"; Unix.h_aliases =3D [||]; > Unix.h_addrtype =3D Unix.PF_INET; Unix.h_addr_list =3D [|; > |]} > # val my_addr : Unix.inet_addr =3D > # val my_entry_byaddr : Unix.host_entry =3D > {Unix.h_name =3D "CNCHZUR2497"; Unix.h_aliases =3D [||]; > Unix.h_addrtype =3D Unix.PF_INET; Unix.h_addr_list =3D [||]} > # val my_full_name : string =3D "CNCHZUR2497" > # val s_descr : Unix.file_descr =3D > # Exception: Unix.Unix_error (Unix.EINVAL, "getsockname", ""). > # > > - > -----------------------------------------------------------------------= ----- > - ------------------------------------------------- > > By the way: where can I find the domain_of function of page 630. Here i= s > the > code I used from the book: > > > Harald > > > -----BEGIN PGP SIGNATURE----- > Version: PGP Desktop 9.0.1 (Build 2185) > > iQA/AwUBQ3stzKW2pktsM+Z9EQKiawCg33hDISm9FUVuJIKF2oFiQJLdhIsAoLE3 > fOf8ojkhqDaz47CqeERZdO64 > =3DAsBR > -----END PGP SIGNATURE----- > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > ------------------------------------------------------------ Gerd Stolpmann * Viktoriastr. 45 * 64293 Darmstadt * Germany gerd@gerd-stolpmann.de http://www.gerd-stolpmann.de ------------------------------------------------------------