alternative for deprecated CFStreamCreatePairWithSocket

371 views Asked by At

The Apple docs mark CFStreamCreatePairWithSocket as deprecated since IOS 15.0. What would be a related successor ? We use CFSocket/NSStream functions currently to have event driven network reads/writes in a runloop.

1

There are 1 answers

0
Leo On

For the record, we ended up rewriting our code to use plain Berkeley sockets together with the GCD dispatch_source machinery ... there is a working socket server sample not triggering the local network prompt at https://github.com/leopatras/GCDSimpleSocketServer/

The dispatch_source_zzz functions allow a similar event driven approach like the CFStreamCreatePairWithSocket function (and even less code). See https://github.com/leopatras/cfsocket for comparison with the old CFSocket stuff. As this is anyway deprecated and triggers the local network prompt in some situations: don't use it anymore.

I had an intensive exchange with the Apple support about this topic, they did recommend using the new Network framework functions instead of Berkeley sockets (See https://developer.apple.com/documentation/network?language=objc) and I tried hard to use them however I failed to create a simple reliable working echo server with those functions in obj-C (didn't try the Swift route).