Re: Using CFSocket to connect
Re: Using CFSocket to connect
- Subject: Re: Using CFSocket to connect
- From: Mike Laster <email@hidden>
- Date: Tue, 02 Jul 2002 14:40:16 -0400
On 7/2/02 2:30 PM, "Douglas Davidson" <email@hidden> wrote:
>
>
On Tuesday, July 2, 2002, at 10:57 AM, Mike Laster wrote:
>
>
> Does the fact that I need to explicitly create my own timer mean that
>
> the
>
> timeout argument is ignored in the current implementation?
>
>
The timeout argument to CFSocketConnectToAddress() is used as follows:
>
if the timeout is > 0, the call is blocking for the time specified. If
>
the timeout is 0, the call is blocking until the TCP stack decides the
>
connect attempt has succeeded or failed. If the timeout is < 0, the
>
call is non-blocking, and the connect attempt continues in the
>
background. You can then use the connect callback to be notified in the
>
run loop when it succeeds or fails. It sounds like the last option is
>
what you wanted, plus a timer to notify you if it's taking too long.
This is the part I'm confused about. If I have a timeout of say 5 seconds,
then the connect callback WILL be called in 5 seconds, whether the connect
succeeded or failed, right? If I can count on getting this callback, why do
I need to create ANOTHER timer to detect when I ran into the timeout?
>
A background connect attempt sounds like a good way to solve this,
>
especially if you need to have other things going on in the meantime.
>
1s might be a little short, unless your machines are very close
>
together, but you should be able to determine an appropriate interval by
>
testing.
With background connection now as an option to me, I could actually try to
connect to all servers in the list simultaneously, use the first one that
succeeds, and then disconnect any others that happen to get connections.
This could be a bit resource intensive on the server, but it would allow for
the quickest possible connect on the client side.
All of the machines are on the same network, connected via switched 100Mbit
ethernet. From what I've seen, if I don't get in within the first second,
the remaining 1 minute 59 seconds never get me in either :-)
--
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.