Hi, what I want to do is enable a simple bonjour service on my ipod touch. And after I publish my custom bonjour service, the delegator did not get "netServiceDidPublish:" call. I also check there is not any error message from "netService:(NSNetService *)sender didNotPublish:". Below is my code section:
// AsyncSocket class comes from an awesome project: cocoa async socket.
// http://code.google.com/p/cocoaasyncsocket/
AsyncSocket* listenSocket;
listenSocket = [[AsyncSocket alloc] initWithDelegate:self];
if (![listenSocket acceptOnPort:0 error:&error])
{
NSLog(@"Error starting server: %@", error);
return NO;
}
int port = [listenSocket localPort];
NSLog(@"Server started on port: %hu", port);
isRunning = YES;
// register itself to bonjour service.
netService = [[[NSNetService alloc] initWithDomain:@"local."
type:@"_sampleservice._tcp"
name:@"myservice"
port:port] autorelease];
if (!netService)
{
NSLog(@"Failed to enable net service");
[listenSocket disconnect];
return NO;
}
[netService setDelegate:self];
[netService scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
//[netService publishWithOptions:NSNetServiceNoAutoRename];
[netService publish];
After this code section, I can get "netServiceWillPublish" delegated call, but no "netServiceDidPublish" Does somebody have any idea? Thanks in advance.