【问题标题】:"InternalIOException getAddrInfo: does not exist (error 10093)" on Windows 8Windows 8 上的“InternalIOException getAddrInfo:不存在(错误 10093)”
【发布时间】:2013-10-03 12:50:23
【问题描述】:

为什么这么简单的代码不起作用?

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

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

这会导致以下错误:

TestConduit.exe:InternalIOException getAddrInfo:不存在 (错误 10093)

【问题讨论】:

    标签: windows http haskell conduit http-conduit


    【解决方案1】:

    您必须使用 withSocketsDo 来初始化套接字。 像这样:

    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
    

    【讨论】:

    • 实际上,无论是否在 Windows 上,您都应该始终使用 withSocketsDo。那么你永远不会有这个问题。 :-)
    • 我很好奇为什么这个初始化没有在幕后或按需自动发生?
    • @The_Ghost 或设计为使类型良好的代码不会崩溃,对吗?在 haskell 中这种事情真的没有任何借口。
    • 是的,但是我们可以放很多其他的东西。我们可以在部件上使用SocketsDo 制动,并让人们每次都对其进行初始化。我认为这是无稽之谈。如果有办法让人们隐式编写更正确的代码,那就更好了。
    • 感谢这为我解决了问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-22
    • 1970-01-01
    • 1970-01-01
    • 2014-10-12
    • 1970-01-01
    • 2014-08-22
    相关资源
    最近更新 更多