Re: bsd sockets & http
Re: bsd sockets & http
- Subject: Re: bsd sockets & http
- From: Jens Bauer <email@hidden>
- Date: Thu, 18 Jul 2002 12:36:23 +0200
Hi Chaz,
I didn't read your code carefully yet, but I think you should be aware
that not all HTTP servers work as you may expect.
If you test against Apache, you're fine. -You won't run into any real
problems here. Good server.
If you use Netscape Enterprise (I know there are problems with 3.5 at
least) or Microsoft IIS, you will definately be in a bad mood for at
least a few weeks, until you've found out how to work around the problems.
Reading your source again, yes, I think the easiest/best/normal way is to
use read().
Are you sure the HTTP header you send is correct ?
Some servers do not support HTTP 1.0, so you would most likely have to
send HTTP 1.1 headers.
I'll try and dig in my sources, to find information about the HTTP 1.1
header I've sent, but while I'm looking, you can find the result faster
by using Google. (in this case, try www.google.com/linux) ;)
On Wed, 17 Jul, 2002, Chaz <email@hidden> wrote:
>
Hello:
>
>
I'm currently reading up on bsd sockets and I've run into a problem while
>
trying to make a sample http client. Here's what I've done:
>
>
socket()
>
bind() // to a random port - i don't think this is necessary for an http
>
client, but to my knowledge it shouldn't hurt.
>
connect() // to the http server on port 80
>
>
while ( bytes<strlen(kServRequest) )
>
{
>
error = send( sock, kServRequest+bytes, strlen(kServRequest), 0 );
>
if ( error==-1 )
>
[[NSAssertionHandler currentHandler]
>
handleFailureInMethod:@selector(checkInternetForUpdate) object:self
>
file:nil lineNumber:NULL description:@"send failed"];
>
else
>
bytes += error;
>
} // Might be a weird way to do this, but it is a sample after all.
>
The message sent is "GET /" which works in telnet.
>
read() // similarly to how I sent, making sure all the data has arrived.
>
But no data ever does arrive.
>
close()
>
>
From playing around with telnet, it seems the http server closes the
>
connection when it's done sending, but I'm a little confused on how the
>
server replies. When running the sample, I seem to enter an infinite loop
>
when reaching my read() routine. Should I not use read()? What needs to
>
be done to catch the response from the http server?
Love,
Jens
--
Jens Bauer, Faster Software.
-Let's make the World better, shall we ?
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.