module Main where

import Network.Socket
import System



main = do s <- socket AF_INET Stream 0
          arg <- getArgs
          let shost = head arg
              port  = PortNum 51777
          host <- inet_addr shost
          putStrLn "Making the server..."
          bindSocket s (SockAddrInet port host)
          b <- sIsBound s
          putStrLn "Socket bounded!"
          listen s 5
          putStrLn "Listening OK"
          putStrLn "Waiting for clients..."
          (s', c) <- accept s
          putStrLn "Client found!"
          str <- recv s' 255
          putStr "Message received:"
          putStr str




foo :: Word16 -> Word16
foo w16 = shiftL (fromIntegral a) 8 .|. fromIntegral b
  where a = fromIntegral w16 :: Word8
        b = fromIntegral (shiftR w16 8) :: Word8
