Question

erm, now I trying to do a messaging between both client instead of client to server. So if I'm not wrong we can't startup service individually but how to see whether is setting up individually or both connect to same service?

My Code for startup the service:

-(void)startService {
    // Start listening socket
    NSError *error;
    self.listeningSocket = [[[AsyncSocket alloc]initWithDelegate:self] autorelease];
    if ( ![self.listeningSocket acceptOnPort:0 error:&error] ) {
        NSLog(@"Failed to create listening socket");
        return;
    }

    // Advertise service with bonjour
    NSString *serviceName = [NSString stringWithFormat:@"Aho- %@",
                                [[NSProcessInfo processInfo] hostName]];
    connectedService = [[NSNetService alloc] initWithDomain:@"" type:@"_cocoaforsci._tcp."
                                                       name:serviceName
                                                       port:1234];
    connectedService.delegate = self;
    [connectedService publish];


}

Any suggestion?

Was it helpful?

Solution

Based on your latest comment, I recommend this article (source is linked near the beginning):

Tutorial: Networking and Bonjour on iPhone

I believe most (if not all) of the article applies just as well to the Mac platform as it does to the iPhone platform.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top