Posted in Python onNovember 26, 2013
module Main where import Network.Socket import Control.Concurrent main :: IO () main = do sock <- socket AF_INET Stream 0 bindSocket sock (SockAddrInet 4242 iNADDR_ANY) listen sock 10240 mainLoop sock mainLoop :: Socket -> IO () mainLoop sock = do conn <- accept sock forkIO $ runConn conn mainLoop sock runConn :: (Socket, SockAddr) -> IO () runConn (sock, tcp) = do sms<-recv sock 1024 peeraddr <- getPeerName sock putStrLn sms runConn (sock, tcp)
haskell实现多线程服务器实例代码
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@