发布网友 发布时间:2022-05-11 03:14
共2个回答
懂视网 时间:2022-05-11 07:36
代码如下:
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)
热心网友 时间:2022-05-11 04:44
Haskell和SQL