Re: Regarding CFRunLoop and multible outgoing connections
Re: Regarding CFRunLoop and multible outgoing connections
- Subject: Re: Regarding CFRunLoop and multible outgoing connections
- From: "Fredrik H. Larsen" <email@hidden>
- Date: Sat, 01 Apr 2006 18:40:32 +0200
Thanks for the fast reply, but I'm still struggling.
The problem is how I should add new outgoing connections to the runloop.
I use CFSocket btw.
Thanks in advance!
On Mar 31, 2006, at 12:13 PM, Quinn wrote:
At 1:56 +0200 31/3/06, Fredrik H. Larsen wrote:
As a previous select() user with while(1){...} implemented, I'm
struggeling using CFRunLoop and multible outgoing connections.
What would you say is the best way to go around this?
What CF APIs are you using? The answer differs depending on
whether you're using CFSocket, or one of the CFStream-style APIs.
o For CFSocket, you can create the socket either unconnected
(CFSocketCreate, CFSocketCreateWithNative,
CFSocketCreateWithSocketSignature) or connected
(CFSocketCreateConnectedToSocketSignature). You can then create a
runloop source (CFSocketCreateRunLoopSource) and add that to your
runloop (CFRunLoopAddSource). For an unconnected socket, you can
then connect it to an address (CFSocketConnectToAddress). You will
then get events as the state of the socket changes. The
kCFSocketConnectCallBack is delivered as the socket connects.
o For CFStream, you can create the stream using various protocol-
specific APIs (CFStreamCreatePairWithSocketToHost for vanilla TCP,
CFReadStreamCreateForHTTPRequest for HTTP, and so on), then
schedule the stream with your runloop
(CFReadStreamScheduleWithRunLoop). You trigger a connect by
opening the stream (CFReadStreamOpen). You will then get events as
the state of the stream changes. For example,
kCFStreamEventOpenCompleted is delivered when the connect is complete.
Share and Enjoy
--
Quinn "The Eskimo!" <http://www.apple.com/
developer/>
Apple Developer Technical Support * Networking, Communications,
Hardware
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40fatalt.net
This email sent to email@hidden
------------------------
Fredrik H. Larsen
_______________________________________________
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