Can we use CFSocketCreateWithSocketSignature() and CFSocketCreateWithNative() for client side implementation?

Hi Eskimo

I am implementing CFSocket API for UDP socket handling, and we have used CFSocketCreate() and CFSocketCreateConnectedToSocketSignature() and it works fine but when I use CFSocketCreateWithSocketSignature() and CFSocketCreateWithNative(), there is problem while implementing (i.e bind failure : err 49 etc.).


Can we use CFSocketCreateWithSocketSignature() and CFSocketCreateWithNative() for client side implementation and how plz give some idea on that?


Thanks,

Sharad

Replies

Can we use

CFSocketCreateWithSocketSignature
and
CFSocketCreateWithNative
for client side implementation

Yes.

how plz give some idea on that?

Error 49 is likely

EADDRNOTAVAIL
, which is coming out of the underlying BSD Socket call. It’s hard to say why this might be happening without more information.

Personally, I tend to use BSD Sockets for all my socket setup and then create a CFSocket, using

CFSocketCreateWithNative
, solely to get run loop integration. The UDPEcho sample code shows how this approach.

OTOH, if I were working on this code today I’d probably skip run loops and CFSocket, and instead use GCD sources for my async support.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

I see “The UDPEcho sample code”. Do you have “The TCPEcho sample code”?