Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] native threads, connect
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-07-25 (09:08)
From: Xavier Leroy <xavier.leroy@i...>
Subject: Re: [Caml-list] native threads, connect
Hi François,

> I'm upgrading some very old network code of mine to Ocaml 3.05,
> and I'm getting confused about the behavior of connect() in 
> bytecode threads vs. native threads. 
> As you know, to get a yieldable connect, you put a socket
> in non-blocking mode, connect, and wait for the socket to
> be writable. That is how connect is written in
> otherlibs/threads/
> Now on the other hand otherlibs/systhreads does not 
> have a specific that defines a connect().

With POSIX or Win32 threads, connect() blocks the calling thread but
not the other threads.  So, Caml just goes ahead and calls connect().

The trick you mention with non-blocking sockets is just a way to
emulate this behavior (block the calling thread but not the other
threads) when system threads are not used and scheduling is performed
at the bytecode level.

> Which is used when compiling with -threads with
> bytecode and native compilers (with Ocaml configured in native
> threads)?

The one in otherlibs/unix in the source distribution.

Hope this helps,

- Xavier
To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: