* Problem with network example of Ocaml book
@ 2005-11-16 13:01 Harald Schmidt
2005-11-16 13:20 ` [Caml-list] " Gerd Stolpmann
2005-11-16 15:25 ` William D. Neumann
0 siblings, 2 replies; 3+ messages in thread
From: Harald Schmidt @ 2005-11-16 13:01 UTC (permalink / raw)
To: caml-list
[-- Attachment #1: Type: text/plain, Size: 1894 bytes --]
-----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 = Unix.gethostname ();;
let my_entry_byname = Unix.gethostbyname my_name;;
let my_addr = my_entry_byname.Unix.h_addr_list.(0);;
let my_entry_byaddr = Unix.gethostbyaddr my_addr;;
let my_full_name = my_entry_byaddr.Unix.h_name;;
let s_descr = Unix.socket Unix.PF_INET Unix.SOCK_STREAM 0;;
let (addr_in, p_num) =
match Unix.getsockname s_descr with
Unix.ADDR_INET (a,n) -> (a,n)
| _ -> failwith "not INET";;
# val my_entry_byname : Unix.host_entry =
{Unix.h_name = "CNCHZUR2497"; Unix.h_aliases = [||];
Unix.h_addrtype = Unix.PF_INET; Unix.h_addr_list = [|<abstr>; <abstr>|]}
# val my_addr : Unix.inet_addr = <abstr>
# val my_entry_byaddr : Unix.host_entry =
{Unix.h_name = "CNCHZUR2497"; Unix.h_aliases = [||];
Unix.h_addrtype = Unix.PF_INET; Unix.h_addr_list = [|<abstr>|]}
# val my_full_name : string = "CNCHZUR2497"
# val s_descr : Unix.file_descr = <abstr>
# Exception: Unix.Unix_error (Unix.EINVAL, "getsockname", "").
#
- ----------------------------------------------------------------------------
- -------------------------------------------------
By the way: where can I find the domain_of function of page 630. Here is the
code I used from the book:
Harald
-----BEGIN PGP SIGNATURE-----
Version: PGP Desktop 9.0.1 (Build 2185)
iQA/AwUBQ3stzKW2pktsM+Z9EQKiawCg33hDISm9FUVuJIKF2oFiQJLdhIsAoLE3
fOf8ojkhqDaz47CqeERZdO64
=AsBR
-----END PGP SIGNATURE-----
[-- Attachment #2: PGPexch.rtf --]
[-- Type: application/octet-stream, Size: 1996 bytes --]
[-- Attachment #3: Schmidt,Harald (SQS Schweiz).vcf --]
[-- Type: application/octet-stream, Size: 264 bytes --]
BEGIN:VCARD
VERSION:2.1
N:Schmidt;Harald
FN:Schmidt,Harald (SQS Schweiz)
ORG:SQS Schweiz AG;SQS Schweiz
TEL;WORK;VOICE:+41 (0) 43 2109 308
ADR;WORK:;Zürich
LABEL;WORK:Zürich
EMAIL;PREF;INTERNET:Harald.Schmidt@sqs-group.ch
REV:20051003T134128Z
END:VCARD
[-- Attachment #4: PGPexch.rtf.sig --]
[-- Type: application/octet-stream, Size: 66 bytes --]
[-- Attachment #5: Schmidt,Harald (SQS Schweiz).vcf.sig --]
[-- Type: application/octet-stream, Size: 66 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] Problem with network example of Ocaml book
2005-11-16 13:01 Problem with network example of Ocaml book Harald Schmidt
@ 2005-11-16 13:20 ` Gerd Stolpmann
2005-11-16 15:25 ` William D. Neumann
1 sibling, 0 replies; 3+ messages in thread
From: Gerd Stolpmann @ 2005-11-16 13:20 UTC (permalink / raw)
To: anobject; +Cc: caml-list
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 = Unix.gethostname ();;
> let my_entry_byname = Unix.gethostbyname my_name;;
> let my_addr = my_entry_byname.Unix.h_addr_list.(0);;
> let my_entry_byaddr = Unix.gethostbyaddr my_addr;;
> let my_full_name = my_entry_byaddr.Unix.h_name;;
> let s_descr = Unix.socket Unix.PF_INET Unix.SOCK_STREAM 0;;
> let (addr_in, p_num) =
> match Unix.getsockname s_descr with
> Unix.ADDR_INET (a,n) -> (a,n)
> | _ -> failwith "not INET";;
>
> # val my_entry_byname : Unix.host_entry =
> {Unix.h_name = "CNCHZUR2497"; Unix.h_aliases = [||];
> Unix.h_addrtype = Unix.PF_INET; Unix.h_addr_list = [|<abstr>;
> <abstr>|]}
> # val my_addr : Unix.inet_addr = <abstr>
> # val my_entry_byaddr : Unix.host_entry =
> {Unix.h_name = "CNCHZUR2497"; Unix.h_aliases = [||];
> Unix.h_addrtype = Unix.PF_INET; Unix.h_addr_list = [|<abstr>|]}
> # val my_full_name : string = "CNCHZUR2497"
> # val s_descr : Unix.file_descr = <abstr>
> # Exception: Unix.Unix_error (Unix.EINVAL, "getsockname", "").
> #
>
> -
> ----------------------------------------------------------------------------
> - -------------------------------------------------
>
> By the way: where can I find the domain_of function of page 630. Here is
> the
> code I used from the book:
>
>
> Harald
>
>
> -----BEGIN PGP SIGNATURE-----
> Version: PGP Desktop 9.0.1 (Build 2185)
>
> iQA/AwUBQ3stzKW2pktsM+Z9EQKiawCg33hDISm9FUVuJIKF2oFiQJLdhIsAoLE3
> fOf8ojkhqDaz47CqeERZdO64
> =AsBR
> -----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
------------------------------------------------------------
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] Problem with network example of Ocaml book
2005-11-16 13:01 Problem with network example of Ocaml book Harald Schmidt
2005-11-16 13:20 ` [Caml-list] " Gerd Stolpmann
@ 2005-11-16 15:25 ` William D. Neumann
1 sibling, 0 replies; 3+ messages in thread
From: William D. Neumann @ 2005-11-16 15:25 UTC (permalink / raw)
To: Harald Schmidt; +Cc: caml-list
On Wed, 16 Nov 2005, Harald Schmidt wrote:
> 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?
Well, this works fine on my OS X and Linux machines, so I'm guessing that
it has something to do with cygwin. Unfortunately I don't know enough
about it to provide much help...
> By the way: where can I find the domain_of function of page 630. Here is the
> code I used from the book:
Do you mean the one in the "A Generic Server" section (page 632 in my
copy)? If so, I have no idea where theirs comes from, but you can use
the Unix.domain_of_socket function in the Unix library.
William D. Neumann
---
"There's just so many extra children, we could just feed the
children to these tigers. We don't need them, we're not doing
anything with them.
Tigers are noble and sleek; children are loud and messy."
-- Neko Case
Life is unfair. Kill yourself or get over it.
-- Black Box Recorder
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-11-16 15:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-16 13:01 Problem with network example of Ocaml book Harald Schmidt
2005-11-16 13:20 ` [Caml-list] " Gerd Stolpmann
2005-11-16 15:25 ` William D. Neumann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox