• 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
Getting a HTTP response with read streams
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Getting a HTTP response with read streams


  • Subject: Getting a HTTP response with read streams
  • From: Maarten Kools <email@hidden>
  • Date: Tue, 19 Dec 2006 15:00:09 +0100

Hi,

I'm retrieving an XML file from a HTTP server using a CFReadStreamRef. However, I'm having some troubles determining whether there's a valid connection or not.

I've got the following bit of code (all in a separate thread):

ReadStream = CFReadStreamCreateForHTTPRequest( kCFAllocatorDefault, Request);
if( !ReadStream) ThrowRuntimeError( "CFReadStreamCreateForHTTPRequest failed");


if( !CFReadStreamOpen( ReadStream)) ThrowRuntimeError( "CFReadStreamOpen failed");

UInt32 StatusCode = 0;
CFHTTPMessageRef ResponseHeader = NULL;
while( !ResponseHeader)
{
ResponseHeader = (CFHTTPMessageRef)CFReadStreamCopyProperty( ReadStream, kCFStreamPropertyHTTPResponseHeader);
if( !ResponseHeader) continue;


StatusCode = CFHTTPMessageGetResponseStatusCode( ResponseHeader);
}
if( ResponseHeader) CFRelease( ResponseHeader);


Works perfectly when there's a valid network connection. However, once you unplug the network the problem arises. Instead of failing to open the read stream (like I expected) it just opens without any error, but it obviously never gets the response headers so it just hangs there.

Is there any way to either detect a network connection, or to determine that the request failed?

Thanks,

Maarten Kools
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Getting a HTTP response with read streams
      • From: Frederick Cheung <email@hidden>
    • Re: Getting a HTTP response with read streams
      • From: Dominik Pich <email@hidden>
  • Prev by Date: Re: Presence of ip-up script destroys VPN connectivity?
  • Next by Date: Getting a HTTP response with read streams
  • Previous by thread: Re: Presence of ip-up script destroys VPN connectivity?
  • Next by thread: Re: Getting a HTTP response with read streams
  • Index(es):
    • Date
    • Thread