Browse thread
[Caml-list] Unix.file_descr -> int ???
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Xavier Leroy <xavier.leroy@i...> |
| Subject: | Re: [Caml-list] Unix.file_descr -> int ??? |
> I was trying to trace a code with some significant amount of
> select'ed fds. At some point, I faced the fact that I just
> have no way to "show" a descriptor value.
OK, if it's just for debugging, and only intended to run under Unix,
you could use the following:
external int_of_filedesc: Unix.file_descr -> int = "%identity"
> I know almost nothing about win32, but I was very surprised
> to discover that win32 has functions, isomorphic to
> low-level unix calls. However, I suspect (I don't have win32
> headers to look in just now) that HANDLE is again a
> "typedef" of intteger.
Not really. It's a typedef of void *. Values of this type look like
small integers, but no guarantees of this kind are given in the Win32
specs. Moreover, a Unix.file_descr under Windows is not a HANDLE, but
a pair of a HANDLE and a flag saying whether it's a socket or not.
See, we really need type abstraction to hide these details :-) And
also to catch common errors like confusing the "fd" and "length"
parameters to the read() or write() functions (in C).
- Xavier Leroy
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners