Created
March 20, 2015 15:28
-
-
Save queertypes/73b894d77f37a790ae8d to your computer and use it in GitHub Desktop.
Echo Client
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE OverloadedStrings #-} | |
module Client where | |
import Network.Socket hiding (recv) | |
import Network.Socket.ByteString | |
run :: IO () | |
run = do | |
addrInfo <- getAddrInfo Nothing (Just "localhost") (Just "3000") | |
let addr = head addrInfo | |
sock <- socket (addrFamily addr) Stream defaultProtocol | |
connect sock (addrAddress addr) | |
sendAll sock "Hi!" | |
msg <- recv sock 1024 | |
sClose sock | |
print msg | |
main :: IO () | |
main = withSocketsDo run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment