module Main where import Network.Server import Network.Socket import Control.Monad import System.IO -- start a TCP (stream) echo server on IPv6 and IPv4 main :: IO () main = do let port = 60000 ip6 = Server (SockAddrInet6 port 0 (0, 0, 0, 0x1) 0xe) Stream echo ip = Server (SockAddrInet port (ipAddress (127, 0, 0, 1))) Stream echo multiServe [ip6, ip] -- the simple echo server routine echo :: ServerRoutine echo (h,n,p) = do l <- hGetLine h hPutStrLn h l hFlush h when (l/="quit") (echo (h,n,p))