haskell/network — pull request #79 by joeyadams (2012-12-20 16:35:48+00:00)
Title: Switch to nonblocking sockets on Windows

This pull request addresses issue #75: [Make network I/O interruptible on Windows][1]. It works by switching to nonblocking sockets on Windows, and calling `select()` from a forked thread with a timeout.

Please review these commits. I'm not ready for them to be merged yet, as I still want to do more testing.

My goal is to get the [http-conduit][2] testsuite to pass on Windows. Currently, it fails (with or without my changes), producing output like this:

```
redirect
user error (accept: can't perform accept on socket ((AF_INET,Stream,0)) in status Closed)
- ignores large response bodies FAILED [2]
user error (accept: can't perform accept on socket ((AF_INET,Stream,0)) in status Closed)

user error (accept: can't perform accept on socket ((AF_INET,Stream,0)) in status Closed)
1) no status message works FAILED (uncaught exception)
user error (accept: can't perform accept on socket ((AF_INET,Stream,0)) in status Closed)
GHC.IO.Exception.IOException (Network.Socket.ByteString.recv: failed (Unknown error))
user error (accept: can't perform accept on socket ((AF_INET,Stream,0)) in status Closed)
```

I suspect [warp][3] is closing sockets too soon, but I haven't found the root cause yet.

[1]: https://github.com/haskell/network/issues/75
[2]: http://hackage.haskell.org/package/http-conduit
[3]: http://hackage.haskell.org/package/warp