我一直在試圖寫一個圍棋客戶端哈斯克爾服務器。對於Haskell TCP服務器,我只是使用Network.Socket
。每當我嘗試運行hWaitForInput
,我收到此錯誤:哈斯克爾TCP服務器,fd是太大錯誤
fdReady: fd is too big.
這裏是服務器端的代碼 -
connHandler :: (Socket, SockAddr) -> IO()
connHandler (sock, _) = do
putStrLn "Starting Handler"
handle <- socketToHandle sock ReadWriteMode
hSetBuffering handle LineBuffering
hPutStrLn handle "Hello Client!"
putStrLn "Waiting for Input"
success <- hWaitForInput handle (1000*10)
putStrLn "Wait done"
if success
then do
putStrLn "Client timed out"
else do
msg <- hGetLine handle
putStrLn msg
hClose handle
轉到客戶端接收和打印服務器的消息(「你好客戶!」)但哈斯克爾服務器打印「等待輸入」
我只是[開了一個bug(https://ghc.haskell.org/trac/ghc/ticket/14530#ticket)。讓我們看看會發生什麼...... –