Skip to content
This repository
Fetching contributors…

Cannot retrieve contributors at this time

file 18 lines (16 sloc) 0.567 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
-- Echo client program
module Main where

import Network.Socket hiding (recv)
import Network.Socket.ByteString (recv, sendAll)
import qualified Data.ByteString.Char8 as C

main :: IO ()
main = withSocketsDo $
    do addrinfos <- getAddrInfo Nothing (Just "") (Just "3000")
       let serveraddr = head addrinfos
       sock <- socket (addrFamily serveraddr) Stream defaultProtocol
       connect sock (addrAddress serveraddr)
       sendAll sock $ C.pack "Hello, world!"
       msg <- recv sock 1024
       sClose sock
       putStr "Received "
       C.putStrLn msg
Something went wrong with that request. Please try again.