English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
windows, threads and sockets
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2009-08-07 (08:40)
From: Sylvain Le Gall <sylvain@l...>
Subject: Re: windows, threads and sockets
On 07-08-2009, Christoph Bauer <christoph.bauer@lmsintl.com> wrote:
> Hi,
> I'm using OCaml 3.11.0. My question is about my program,
> which used to work fine under windows and linux. The program
> is a daemon, which waits for socket connections and respondse
> to queries.
> Now I added an extension with uses threads. Everything is
> find on linux, but I have a very strange behaviour on windows.
> For the troubles it is sufficient to link agains threads and compile the
> main program with -thread. Without it everything is fine again.
> I'm not quite sure what is going on, but my best bet is this: the main
> loop waits for the sockets with
> Unix.select listOfSockets [] [] timeout
> One socket is the listener socket on which new connections 
> are made. Unix.select returns a list of sockets. Initially
> it must be the listener socket. This is checked with a compare
>   socket = listenSocket 
> and this seems to be suddenly wrong (just in the thread case).

Do you mean that the following code is wrong with 3.11.1 and not 3.10.2:

let res_listener = Unix.select listOfSockets [] [] timeout
(List.nth res_listener 0) = listenSocket

Can you find listenSocket in the result elsewhere ?

Sylvain Le Gall