Brett Thompson! wrote:

> Of *course* this is "cost effective" in C!!

Only if you ignore large chunks of the HTTP protocol.

> You just have to do a tiny bit of sockets...

... and a fair amount of parsing HTTP responses.

> C should be faster than an interpreted language,

The final program will be faster to run; however, it will take vastly
longer to write.

> although most of the delay for this sort of thing is probably due to the
> speed of the network...
> 
> Attached is a rather simple example that I wrote real quickly... Seems to
> get the job done though, just write it to stdout.

This doesn't cope with HTTP redirects, ignores the Content-Length:
header (only the first <content-length> bytes of the response are part
of the content; the rest are `trailing garbage'), only implements
HTTP/0.9 (so it won't work with any sites which use HTTP/1.1 virtual
hosting), has port 80 hardcoded (HTTP servers can run on any port),
won't work with password-protected pages, ...

Also, setting the socket to non-blocking mode is totally the wrong
thing to do. This program will eat 100% CPU until the connection is
closed. It's not as if the program actually makes any use of the fact
that the socket is non-blocking.

-- 
Glynn Clements <[EMAIL PROTECTED]>

Reply via email to