MLton.Socket improvement
Stephen Weeks
MLton@sourcelight.com
Tue, 18 Dec 2001 09:52:25 -0800
> I don't understand your claim, but I think you were confused. At the moment,
> the socket you do accept's on has to be closed by knowing that it is really
> a file descriptor and using Posix.IO.close on it. If it were wrapped up in
> closures that you could never close that file descriptor. I agree that the
> one you get as a result of an accept is wrapped into one of the streams so it
> will get get closed. Did I miss something?
Ah. I believe this is a bug in the current way sockets are done in
MLton. Right now, the socket that is created by MLton.Socket.listen
is never closed. You should fix that while you're at it.
> In the mean time, I seem to have gotten a way to convert a file descriptor
> into a TextIO.outstream in SML/NJ. The only trick was that you have to provide
> both writeVec and writeArr functions, and for the latter there isn't a way
> to convert the CharArray into a Word8Array without doing a copy.
Please contribute this code to lib/mlton-stubs-in-smlnj/mlton.sml, the
MLton.TextIO.newOut function.