jaspervdj/websockets — pull request #38 by scvalex (2013-02-11 14:45:35+00:00)
Title: Let the user supply the socket for client connections

`Network.WebSocket.Client.connectWith` doesn't quite work for me. The problem is that it sets up the socket:

connectWith host port path origin wsProtocols app = do
...
-- Connect to server
sock <- S.socket S.AF_INET S.Stream S.defaultProtocol
addrInfos <- S.getAddrInfo Nothing (Just host) (Just $ show port)
S.connect sock (S.addrAddress $ head addrInfos)

My problem is that, on my machine, `getAddrInfo` returns multiple values, but the one selected by `head` doesn't always work (`connect` fails due to various errors).

Additionally, I'd like to be able to change the socket's options.

The changes in this pull request introduce a new function, `N.WS.Client.connectWith'`, which takes a socket argument. The changes are backwards compatible.

On an unrelated note, since you're not specifying any hints to `getAddrInfo`, it also returns configurations for UDP and IP sockets; was this intended?