Simple sockets sample?
Jens Petersen
juhp@01.246.ne.jp
28 Jan 2002 17:39:54 +0900
Jens Petersen <juhp@01.246.ne.jp> writes:
> "Dominic Cooney" <dominic@dcooney.com> writes:
>
> > > sendTo host port "GET / HTTP/1.0\r\n\r\n";
>
> 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...
As Ketil Malde pointed out to me, Dominic's crlfcrlf
sequence is indeed necessary. Ie after replacing the above
hPutStrLn line with
hPutStr h "GET / HTTP/1.0\r\n\r\n"
my program finally works. As Simon comments in his
webserver, some kinding of transfer coding would be nice to
avoid this kind of hassle.
<blush/>
Jens