• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Using CFSocket to connect
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using CFSocket to connect


  • Subject: Re: Using CFSocket to connect
  • From: Douglas Davidson <email@hidden>
  • Date: Tue, 2 Jul 2002 11:30:32 -0700

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.

The problem I'm trying to solve is how to provide transparent failover
services. A client has a list of server:port pairs which provide a given
service. What I do is try to connect to #0. If that connection fails (or
dies at some later point), it automatically fails over to server #1, then
#2, etc. The problem I originally ran into was that if the host was
entirely down for server #0, it would take 2 minutes before the TCP/IP stack
would realize this fact, which would defeat the purpose of failing over.

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.

I haven't worked myself up to CFStreams yet. I'm still working on migrating
my threads-and-bsdsockets code into the CF world. I've been wanting to
migrate away from my custom network code forever, since the thread
interaction issues are a nightmare to debug. However, there has never been
an API until CFSocket that I could move to.

How efficient are CFStreams with large streams? I have a distribution
architecture that moves about 400MB/day around multiple machines. This
seems like it could be ideal if it can handle it quickly and without undo
memory or CPU load.

I would expect CFStream to be pretty efficient for this sort of task.

Douglas Davidson
_______________________________________________
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.

  • Follow-Ups:
    • Re: Using CFSocket to connect
      • From: Mike Laster <email@hidden>
References: 
 >Re: Using CFSocket to connect (From: Mike Laster <email@hidden>)

  • Prev by Date: Re: Using CFSocket to connect
  • Next by Date: Re: Using CFSocket to connect
  • Previous by thread: Re: Using CFSocket to connect
  • Next by thread: Re: Using CFSocket to connect
  • Index(es):
    • Date
    • Thread