gpt4 book ai didi

windows - 在 Windows 中的 WAI 上运行 Warp 时遇到问题

转载 作者:可可西里 更新时间:2023-11-01 10:26:55 33 4
gpt4 key购买 nike

我已经在 (Wai) 上为 (Warp) 编写了一个简单的 Hello World 应用程序。它在 Ubuntu Linux 中运行良好,更复杂的应用程序也是如此。但我什至无法让这个 Hello World 应用程序在 Windows 中运行。我在 Windows 7 Home Premium SP1 32 位上使用 Haskell Platform(安装文件 2012.2.0.0)。

这是代码(适用于 Linux):

{-# LANGUAGE OverloadedStrings #-} 

import Network
import Network.Wai
import Network.HTTP.Types (status200)
import Network.Wai.Handler.Warp (run)
-------------------------------------------------------------------------------
application = \_-> return $ responseLBS status200 [("Content-Type", "text/plain")]
"Hello World"

main = withSocketsDo $ do run 3000 application

这些是加载代码和运行(主要)时的 GHCI 消息:

Prelude> :l wai_hello_world.hs
[1 of 1] Compiling Main ( wai_hello_world.hs, interpreted )
Ok, modules loaded: Main.
*Main> main
Loading package bytestring-0.9.2.1 ... linking ... done.
Loading package [ **edited**: blah blah blah - other packages - removed for readability]
Loading package warp-1.3.2 ... linking ... done.

加载代码后,网络服务器似乎没有运行。

我想我可能遇到了一些常见问题 - 如果是这样,请告诉我。

提前感谢所有反馈。

(Update: as noted in an answer below, these errors are solely due to the Ctrl-C action, killing the runtime, and not part of the unexpected behaviour of Wai/Warp in the question.)

If I hit Ctrl-C a few times to break out, I get these messages, or some variety of them:

NIenttweorrrku.pStoecdk.e
t.ace*Main> p: failed (No error)
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)
*Main>
*Main> user error (accept: can't perform accept on socket ((AF_INE,:Sream,0)) in status Closed)
q
Leaving GHCi.

最佳答案

您可能需要使用 withSocketsDo .

关于windows - 在 Windows 中的 WAI 上运行 Warp 时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13739286/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com