Note: this is the stubbed version of module Client. You should
download the lhs version of this
module and replace all parts marked
undefined
.
Eventually, the complete
version will be made available.
Concurrency client
This module goes with the Concurrency lecture. It implements a network client that communicates with a server using sockets.
This module uses the Network.Socket library, which provides basically the same interface to OS sockets as in C.
> -- | Start the client given an IP address and a port. The port should
> -- be a string number > 1024
> client :: HostName -> ServiceName -> IO Handle
> client ip port = do
> (sa:_) <- getAddrInfo Nothing (Just ip) (Just port)
> sock <- socket (addrFamily sa) Stream defaultProtocol
> connect sock (addrAddress sa)
> handle <- socketToHandle sock WriteMode
> hSetBuffering handle (BlockBuffering Nothing)
> return handle