• 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: Can't open CFWriteStream .. AsyncSocket
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can't open CFWriteStream .. AsyncSocket


  • Subject: Re: Can't open CFWriteStream .. AsyncSocket
  • From: J P May <email@hidden>
  • Date: Sun, 15 Aug 2010 10:01:17 +0200

James, FWIW I found that AsyncSocket by DUSTIN VOSS is the superb tcp library

http://homepage.mac.com/d_j_v/FileSharing4.html

maybe it's relevant for what you are doing. As you say, it seems tricky to listen for a TCP connection. Fortunately Voss has done all the hard work in AsyncSocket,

self.listeningServer = [[[AsyncSocket alloc] init] autorelease];
self.listeningServer.delegate = self;
[listeningServer acceptOnPort:66666 error:nil];

then bonjour if necessary.

then He offers a three-step process for incoming connections which are found,

// nb AsyncSockets uses a three step incoming connection process,
// 1. -(void)onSocket:(AsyncSocket *)sock didAcceptNewSocket:(AsyncSocket *)newSocket (get the socket)
// 2. -(BOOL)onSocketWillConnect:(AsyncSocket *)sock (say yes or no - defaults to yes)
// 3. -(void)onSocket:(AsyncSocket *)sock didConnectToHost:(NSString *)host port:(UInt16)port .. done


In fact in many/most cases you can just use part '3' and you're done.

-(void)onSocket:(AsyncSocket *)sock didConnectToHost:(NSString *)host port:(UInt16)port
{
if ( ! [yourStateMachine okToConnectNow] )
{ [sock disconnect]; return; }
blah.yourSocket = [sock retain];
[sock readDataToLength:sizeof(happyProtocol)
withTimeout:-1 tag:0]; // typical primer read command
[yourStateMachine updateAll];
}


for me it's the perfect as-light-as-possible TCP library, it's a miracle. perhaps it's relevant to what you are doing


Never mind. Turns out that the main problem was on the listener end, and that listening for a TCP connection is more complicated than listening for UDP packets, at least when using CFSocket.
James W. Walker, Innoventive Software LLC
<http://www.frameforge3d.com/>


_______________________________________________
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


  • Follow-Ups:
    • Re: Can't open CFWriteStream .. AsyncSocket
      • From: James Walker <email@hidden>
    • Re: Can't open CFWriteStream .. AsyncSocket
      • From: James Walker <email@hidden>
References: 
 >Can't open CFWriteStream (From: James Walker <email@hidden>)
 >Re: Can't open CFWriteStream (From: James Walker <email@hidden>)

  • Prev by Date: Re: Can't open CFWriteStream
  • Next by Date: Re: SCTP. V4 v. V6 addresses... / comparing identies
  • Previous by thread: Re: Can't open CFWriteStream
  • Next by thread: Re: Can't open CFWriteStream .. AsyncSocket
  • Index(es):
    • Date
    • Thread