• 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
CFDataGetBytes causes crash in socket callback
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CFDataGetBytes causes crash in socket callback


  • Subject: CFDataGetBytes causes crash in socket callback
  • From: Liwei <email@hidden>
  • Date: Thu, 2 Oct 2008 01:36:59 +0800

I have setup a socket for UDP using CFSocket and bound it to localhost.

However every time data is received it crashes when I try to copy out
the data for printing. The relevant callback function is this:
void receiveData(CFSocketRef socket, CFSocketCallBackType type,
CFDataRef address, const void *data, void *info){
	UInt8 *databuf;
	CFMutableDataRef localdata =
CFDataCreateMutableCopy(kCFAllocatorDefault, 0, data);
	if(localdata != NULL){
		CFDataAppendBytes(localdata, (UInt8 *)"", 1);
		CFDataGetBytes(localdata,CFRangeMake(0, CFDataGetLength(localdata)), databuf);
		printf("%s", databuf);
	}
	return;
}

It crashes at CFDataGetBytes with a EXEC_BAD_ACCESS

I think it worked in the past (its been some time since I fiddled with
this code) before I shuffled some stuff around. Anyone knows what the
problem might be?
 _______________________________________________
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: CFDataGetBytes causes crash in socket callback
      • From: Frederick Cheung <email@hidden>
  • Prev by Date: Threaded Networking sample code
  • Next by Date: Re: CFDataGetBytes causes crash in socket callback
  • Previous by thread: Threaded Networking sample code
  • Next by thread: Re: CFDataGetBytes causes crash in socket callback
  • Index(es):
    • Date
    • Thread