caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Olivier Pérès" <olivier.peres@laposte.net>
To: Caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] Socket and Threads on windows
Date: Mon, 07 Feb 2005 11:33:29 +0100	[thread overview]
Message-ID: <420743F9.2000703@laposte.net> (raw)
In-Reply-To: <1107765700-e20070018019e5a283e3267b340928dc@rashitoul.net>

Julien Boulnois a écrit :
> let (ic,oc)=(Unix.in_channel_of_descr sock,Unix.out_channel_of_descr sock);;

    According to the manual, none of *_channel_of_descr works on sockets 
on Windows 95/98/Me. What are you using ? As for me, to avoid that kind 
of problems, when writing Amble I made my own send/receive functions. 
Send is trivial (Marshal to string and Unix.write), receive is also 
pretty simple :

let receive_message fd =
     (* 1 - allocate and read the header *)
     let hs = Marshal.header_size in
     let headerbuf = String.create hs in
     let hlen = Unix.read fd headerbuf 0 hs in

     (* 2 - prepare the buffer as a string that has the same size as the 
message
      *     and copy the header in the beginning
      *)
     let ds = Marshal.data_size headerbuf 0 in
     let buf = String.create (hs+ds) in
     String.blit headerbuf 0 buf 0 hs;

     (* 3 - receive the rest of the message (data part) *)
     let dlen = Unix.read fd buf hs ds in

     (* 4 - decoding (unmarshalling) *)
     Marshal.from_string buf 0

    You can get the whole thing from http://home.gna.org/amble/ ; 
licence : GPL.

    Hope this helps,

    Olivier.


  reply	other threads:[~2005-02-07 10:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-07  8:41 Julien Boulnois
2005-02-07 10:33 ` Olivier Pérès [this message]
2005-02-07 11:05   ` Re: [Caml-list] " Julien Boulnois
2005-02-10 16:23     ` OCAML Newby Question: unbound module? Juancarlo Añez
2005-02-11 14:45       ` [Caml-list] " John Prevost

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=420743F9.2000703@laposte.net \
    --to=olivier.peres@laposte.net \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).