Skip to content

Instantly share code, notes, and snippets.

@queertypes
Created March 20, 2015 15:28
Show Gist options
  • Save queertypes/73b894d77f37a790ae8d to your computer and use it in GitHub Desktop.
Save queertypes/73b894d77f37a790ae8d to your computer and use it in GitHub Desktop.
Echo Client
{-# 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