0
我問一個關於信號問題在Windows上使用相同的代碼,這裏是另外一個問題在Haskell,插座聽了未能在Windows
import IO
import Control.Exception hiding (catch)
import Control.Concurrent
import Network
main = withSocketsDo $ do {main'}
main' = listenOn (PortNumber 9900) >>= acceptConnections
acceptConnections sock = do
putStrLn $ "trying to accept" ++ (show sock)-- debug msg
[email protected](h,host,port) <- accept sock
print conn -- debug msg
forkIO $ catch (talk conn `finally` hClose h) (\e -> print e)
acceptConnections sock
talk [email protected](h,_,_) = hGetLine h >>= hPutStrLn h >> hFlush h >> talk conn
我Win7上運行的程序,它看起來像創建成功插座,但我不能telnet,並且netstat沒有顯示任何監聽套接字的過程,有什麼問題嗎?或者,haskell在Windows上有bug?(順便說一下,在這個代碼的debian上完美)
在ghci和編譯時適合我。我在win7 64bit。也許它與你的網絡/防火牆設置有關嗎? – 2012-04-27 08:33:50
爲你的答案,我發現了問題,並回答下面,但我仍然不知道爲什麼你的系統工作正常,你可以在服務器上telnet並獲得回聲? – vzex 2012-04-27 16:15:07