{-# LANGUAGE CPP #-}
module Main where

import Network.Socket

main = do
  (ap:_) <- getAddrInfo (Just hints) (Just "slashdot.org") (Just "80")
  h <- socket AF_INET Stream tcp
#ifdef LINGER
  setSocketOption h Linger 5
  -- ==> Exception: setSocketOption: invalid argument (Invalid argument)
#endif
  connect h (addrAddress ap)
  sClose h
    where
      tcp = 6 -- awk '($1 == "tcp") {print $2}' /etc/protocols
      hints = defaultHints { addrFamily = AF_INET
                           , addrSocketType = Stream
                           , addrProtocol = tcp }
