[MLton-devel] OS.IO.poll portability

Stephen Weeks MLton@mlton.org
Thu, 5 Jun 2003 18:22:00 -0700


Saw the following post on comp.lang.ml

	http://groups.google.com/groups?dq=&hl=en&lr=&ie=UTF-8&group=comp.lang.ml&safe=off&selm=bbnpim%24nvp%241%40wolfberry.srv.cs.cmu.edu

> I'm seeing some differences in behavior between SML/NJ 110.42 and
> MLton. Specifically, When I set up a read poll on a passive socket,
> the OS.IO.poll call in MLton always returns that the socket is
> ready. SML/NJ does not; it only returns that the socket is ready if
> there is a pending connection to the socket.
>
> To me, this looks like a bug in MLton (v 20030312), but the
> specifications of OS.IO.poll, INetSock, and Socket, don't appear to
> have enough detail for me to tell. So how is OS.IO.poll supposed to
> behave in the above case, or is it just not very portable (in which
> case I'll hide the differences behind a functor :) ?

The following program tests his claim.

local
   val s = INetSock.TCP.socket ()
   val _ = Socket.bind (s, INetSock.any 0)
   val _ = Socket.listen (s, 5)
   val l = OS.IO.poll ([OS.IO.pollIn (Socket.pollDesc s)],
		       SOME (Time.fromSeconds 5))
   val _ = print (concat [Int.toString (length l), "\n"])
in
end

Under SML/NJ this prints "1" and under MLton it prints "0".  Looking
at an strace, I see that MLton uses poll while SML/NJ uses select.
I'm not sure how to answer though.  Matthew, could you look into this
and respond to David?

Also, I thought it would be nice to avoid duplication of work in the
future for us to always cc MLton@mlton.org when replying to
MLton-related newsgroup posts.  That way we all know what's going on a
bit sooner than waiting for news and we also can discuss it here.



-------------------------------------------------------
This SF.net email is sponsored by:  Etnus, makers of TotalView, The best
thread debugger on the planet. Designed with thread debugging features
you've never dreamed of, try TotalView 6 free at www.etnus.com.
_______________________________________________
MLton-devel mailing list
MLton-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlton-devel