• 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
Re: [CFSocket] When should a CFSocketRef be invalidated?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [CFSocket] When should a CFSocketRef be invalidated?


  • Subject: Re: [CFSocket] When should a CFSocketRef be invalidated?
  • From: Stéphane Sudre <email@hidden>
  • Date: Thu, 13 Jan 2011 13:03:24 +0100

On 12 janv. 11, at 21:32, Douglas Davidson wrote:

On Jan 12, 2011, at 12:05 PM, Stéphane Sudre wrote:

I have a process that uses CFSocketRef to connect to a TCP server and get some data.

I'm using a run loop source and connect and data callbacks.

When I receive the final kCFSocketDataCallBack with a zero data length, I invalidate the CFSocketRef.

In one case, it works.

In the other, it does not (it crashes).

Calling CFSocketIsValid before calling CFSocketInvalidate just makes the code crash in CFSocketIsValid instead.

The connection is closed by the server in both cases after the server provided the requested data.

You didn't include a backtrace, but CFSocketIsValid() is a very simple function, and a crash there strongly suggests that you are passing in a pointer that does not point to a CFSocket, and most likely does not point to a readable memory location.

I think I found the issue. As far as I can tell it is in my code.

I found part of the solution after finding out that the CFSocket source code is available in CF-Lite.

After looking at the source for the callbacks, it was clear that CFSocketInvalidate is already called by the API when the data length is zero for kCFSocketDataCallBack. It might be worth mentioning that in the documentation somewhere (CFSocketCallBack or CFSocketInvalidate ) IMHO.


_______________________________________________ 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: [CFSocket] When should a CFSocketRef be invalidated?
      • From: "Quinn \"The Eskimo!\"" <email@hidden>
References: 
 >[CFSocket] When should a CFSocketRef be invalidated? (From: Stéphane Sudre <email@hidden>)
 >Re: [CFSocket] When should a CFSocketRef be invalidated? (From: Douglas Davidson <email@hidden>)

  • Prev by Date: Re: [CFSocket] When should a CFSocketRef be invalidated?
  • Next by Date: Re: [CFSocket] When should a CFSocketRef be invalidated?
  • Previous by thread: Re: [CFSocket] When should a CFSocketRef be invalidated?
  • Next by thread: Re: [CFSocket] When should a CFSocketRef be invalidated?
  • Index(es):
    • Date
    • Thread