Bug 17713 - CFSocket Read, Data, and Write events intentionally omitted?
Summary: CFSocket Read, Data, and Write events intentionally omitted?
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 7.0.6.x
Hardware: PC Mac OS
: --- enhancement
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2014-02-11 19:06 UTC by Brendan Zagaeski (Xamarin Team, assistant)
Modified: 2014-11-26 08:55 UTC (History)
5 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Brendan Zagaeski (Xamarin Team, assistant) 2014-02-11 19:06:50 UTC
The Apple documentation for CFSocket mentions the availability of several types of callbacks [1]:


> [1] https://developer.apple.com/library/ios/documentation/CoreFoundation/Reference/CFSocketRef/Reference/reference.html#//apple_ref/c/tdef/CFSocketCallBackType

The Xamarin.iOS bindings for CFSocket only include a `ConnectEvent` and an `AcceptEvent`. Are the other three events intentionally omitted, for example maybe to encourage the use of System.Net.Sockets instead?

Comment 2 Rolf Bjarne Kvinge [MSFT] 2014-02-12 06:07:21 UTC
The general rule is that CoreFoundation isn't fully bound because there are usually equivalent managed alternatives, which leads to more portable code.

What has been implemented so far is usually just because we've needed the code internally in monotouch.dll (or MonoMac.dll/XamMac.dll for that matter).

Any specific reason to use CFSocket instead of System.Net.Socket?
Comment 3 Brendan Zagaeski (Xamarin Team, assistant) 2014-02-12 16:27:19 UTC
Sounds good, thanks! I'll update the enhancement if I hear back from the customer with a specific problem that requires CFSocket instead of System.Net.Socket.
Comment 4 Michael Lukas 2014-03-13 03:14:13 UTC
Hi, Im the customer needing CFSocket sorry for replying so late.

We would love to use System.Net.Socket but we need VOIP Sockets in our app. 

There seems to be only one way to get a VOIP socket which is creating a CFSocket and getting the streams of it, or use CFStream.CreatePairWithSocketToHost to get streams which you can setup with the following code:

void setupVOIP(NSStream stream){
    stream[NSStream.NetworkServiceType] = NSStream.NetworkServiceTypeVoIP;

Which is working but its not perfect.
Streams are nice and everything but a real CFSocket would be better for eventhandling. 

Even better would be a System.Net.Socket which could be setup for VOIP usage.
Comment 5 Rolf Bjarne Kvinge [MSFT] 2014-09-22 10:22:42 UTC

maccore/master: 5b648445c8d7c0264792b667d932d984f5ad8dc2
monotouch/master: e2871526ef3ac1f092668fef2fb5e28fe946a9a7
Comment 6 Miguel de Icaza [MSFT] 2014-09-29 10:07:41 UTC
There is also NSStream.GetBoundStreams for the and NSStream.GetStreamToHost
Comment 7 narayanp 2014-11-26 08:55:57 UTC
With latest build X.iOS, we are getting all 5 events:


Screencast: http://screencast.com/t/uaebjh1C

However, with X.iOS, we were getting only 2 events:


Hence, I am closing this issue with X.iOS