ghci

Julian Assange proff@iq.org
22 Oct 2001 15:55:27 +1000


The following code works fine under ghc, but produces a strange error
under ghci:

        Main> main
        *** Exception: failed
        Action: connect
        Reason: Unknown error 141312000

It is deterministic - i.e I have verified that it isn't a network
fault.

module Main(main) where
import Socket
import IO(hPutStr,hFlush,hGetLine)

alexa_host = "iq.org."

main = connectUp alexa_host 80

connectUp :: Hostname -> Integer -> IO ()
connectUp host  port =
    do
    h <- connectTo host (PortNumber (fromIntegral port))
    hPutStr h "GET / HTTP/1.0 \r\n\r\n"
    hFlush h
    line <- hGetLine h
    putStrLn line


Additionally, I'm a little confused about how to
import the PortNumber constructor from Socket, without
importing everything else. It's behavior seems odd.