• 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
CFReadStreamOpen crash ! ! !
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CFReadStreamOpen crash ! ! !


  • Subject: CFReadStreamOpen crash ! ! !
  • From: "Cool Water" <email@hidden>
  • Date: Thu, 11 May 2006 11:09:42 +0000

Hello,
 
I'm using CFHTTPDownload Sample, i use CFHTTPMessageAppendBytes for HTTPRequest.
 
Why do it crasched my Appl. by ReadStremOpen() function.
 

Thank you for your advice,

My function

--------------------------------------------------------------------------------------------------------------------------------------
.
.
.
CFReadStreamRef    readStreamRef = NULL;
 CFStreamClientContext  ctxt   = { 0, (void*)NULL, NULL, NULL, NULL };
 static EventLoopTimerUPP networkTimeoutTimerUPP;

 UInt8 reqString[]="POST /cgi-bin/ConfigFile?0,0,0,0,0,0,0,0,0 HTTP/1.1\r\nHost: 192.168.1.100\r\nAccept-Language: en\r\nPragma: no-cache\r\nConnection: Keep-Alive\r\nUser-Agent: Mozilla/4.0 (compatible; MSIE 5.23; Mac_PowerPC)\r\nContent-type: multipart/form-data; boundary=---------------------------168071508944249\r\nExtension: Security/Remote-Passphrase\r\nAuthorization: Basic YWRtaW46YWRtaW4=\r\nContent-length: 33992\r\n\r\n";
// HTTP - Post Request Body
 CFDataRef   bodyData = NULL;
 Boolean bAppendRes = false;
CFHTTPMessageRef messageRefRequest= CFHTTPMessageCreateEmpty(kCFAllocatorDefault,true);
 
CFHTTPMessageAppendBytes(messageRefRequest, reqString, strlen((const char*)reqString));
 
 if(CFHTTPMessageIsHeaderComplete(messageRefRequest))
  DebugMsgBox("\pDEBUG","\pHEADER IS COMPLETE");
 else
  DebugMsgBox("\pDEBUG","\pHEADER IS NOT COMPLOETE"); 

 GetBody(&bodyData);
 CFHTTPMessageAppendBytes(messageRefRequest, CFDataGetBytePtr(bodyData), CFDataGetLength(bodyData));
 // Create the stream for the request.
 readStreamRef = CFReadStreamCreateForHTTPRequest( kCFAllocatorDefault, messageRefRequest );
 if ( readStreamRef == NULL )
 {
  goto Bail;
 }
  
    CFReadStreamSetProperty(readStreamRef, kCFStreamPropertyHTTPAttemptPersistentConnection, kCFBooleanTrue);
  // Set the client notifier
 if ( CFReadStreamSetClient( readStreamRef, kNetworkEvents, ReadStreamClientCallBack, &ctxt ) == false )
  goto Bail;
 

 // Schedule the stream
 CFReadStreamScheduleWithRunLoop( readStreamRef, CFRunLoopGetCurrent(), kCFRunLoopCommonModes ); 

 // Start the HTTP connection
 if ( CFReadStreamOpen( readStreamRef ) == false ) //// <- Crashed HERE , WHY ??????
  goto Bail;
 
 // Set up a watch dog timer to terminate the download after 5 seconds
 if ( networkTimeoutTimerUPP == NULL ) 
  networkTimeoutTimerUPP = NewEventLoopTimerUPP( NetworkTimeoutTimerProc );
 
 if ( gNetworkTimeoutTimerRef != NULL )
  RemoveEventLoopTimer( gNetworkTimeoutTimerRef );
 
 InstallEventLoopTimer( GetCurrentEventLoop(), kEventDurationSecond *10, 0, networkTimeoutTimerUPP, (void*)readStreamRef, &gNetworkTimeoutTimerRef );
 
Bail: 
 if ( bodyData != NULL)   CFRelease( bodyData );
 if ( messageRefRequest != NULL )   CFRelease( messageRefRequest );
 if ( readStreamRef != NULL )
    {
        CFReadStreamSetClient( readStreamRef, NULL, NULL, NULL );
        CFRelease( readStreamRef );
    }
.
.
.
--------------------------------------------------------------------------------------------------------------------------------------
 _______________________________________________
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

  • Prev by Date: Re: Read stream and proxies
  • Next by Date: kernel events
  • Previous by thread: Re: CFHTTPMessageAddAuthentication query
  • Next by thread: kernel events
  • Index(es):
    • Date
    • Thread