I realize that my use of the API was incredibly naïve and that I should have been using h* methods with the handle returned from connectTo. But it is connectTo that is failing as described.
It fails interactively too with ghci, and regardless of using Server "http" or PortNumber 80. The revised code below unfortunately gives the following error: Main> main *** Exception: does not exist Action: getProtocolByName Reason: no such protocol entry The code is: > module Main(main) where > import IO > import Socket > main :: IO () > main = do > h <- connectTo "www.yahoo.com" (PortNumber 80) > hPutStrLn h "GET / HTTP/1.0\n" > response <- hGetContents h > putStrLn response I suppose the wits will tell me to use Linux instead? Sigh... Dominic Cooney -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Jens Petersen Sent: Monday, 28 January 2002 4:33 PM To: Dominic Cooney Cc: [EMAIL PROTECTED] Subject: Re: Simple sockets sample? "Dominic Cooney" <[EMAIL PROTECTED]> writes: > Does anybody know of a simple GHC Socket sample? I want to retrieve an > HTTP URL, but I keep getting errors like this: Funny I was trying to do the same this morning on the way to work. > A minimal program that exhibits the problem is below. I am using GHC > 5.02 on Win XP Pro. When I enter the request via telnet, I do get a > response. > > I assume I am making some terrible newbie mistake, so if anyone could > point it out it would be appreciated. > > main = withSocketsDo $ do { > > connectTo host port; > > sendTo host port "GET / HTTP/1.0\r\n\r\n"; > > response <- recvFrom host port; > > putStrLn response Hmmm, I was trying something more like (under Linux): do h <- connectTo host port hPutStrLn h "GET / HTTP/1.0\n" response <- hGetContents h putStr response Unfortunately this hangs waiting for the response. Don't know why yet... Jens _______________________________________________ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell