"InternalIOException getAddrInfo: does not exist (error 10093)" on Windows 8
Asked Answered
O

1

10

Why is such simple code not working?

import Network.HTTP.Conduit
import qualified Data.ByteString.Lazy as L

main :: IO ()
main = simpleHttp "http://www.dir.bg/" >>= L.putStr

It results in the following error:

TestConduit.exe: InternalIOException getAddrInfo: does not exist (error 10093)

Ogdan answered 3/10, 2013 at 12:50 Comment(0)
O
15

You have to use withSocketsDo to initialize sockets. Like this:

import Network.HTTP.Conduit
import qualified Data.ByteString.Lazy as L
import Network (withSocketsDo)

main :: IO ()
main = withSocketsDo
      $ simpleHttp "http://www.dir.bg/" >>= L.putStr
Ogdan answered 3/10, 2013 at 12:50 Comment(4)
Actually, you should always use withSocketsDo, if on Windows or not. Then you'll never have this problem. :-)Jeneejenei
I'm curious why this initialization is not happening behind the curtains or on-demand automatically?Ogdan
@Ogdan or designed so that well-typed code doesn't blow up, right? There's really no excuse for this kind of thing in haskell.Hornblende
Yes, but we could put a lot of other stuff. We could brake withSocketsDo on parts and make people initialize it every time. I think this is non-sense. If there are a ways to make people write more correct code implicitly it will be better.Ogdan

© 2022 - 2024 — McMap. All rights reserved.