• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
bsd sockets & http
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bsd sockets & http


  • Subject: bsd sockets & http
  • From: Chaz <email@hidden>
  • Date: Wed, 17 Jul 2002 21:54:02 -0600

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?

Thanks
- Chaz
_______________________________________________
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.

  • Follow-Ups:
    • Re: bsd sockets & http
      • From: "Philip D. Wasson" <email@hidden>
    • Re: bsd sockets & http
      • From: Jens Bauer <email@hidden>
  • Prev by Date: Re: what's the equvilent call of OTInetQuery (OT) in sockets?
  • Next by Date: Re: bsd sockets & http
  • Previous by thread: RE: what's the equvilent call of OTInetQuery (OT) in sockets?
  • Next by thread: Re: bsd sockets & http
  • Index(es):
    • Date
    • Thread