启动服务的我的代码:
-(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];
}
有什么建议吗?
答案 0 :(得分:2)
根据您的最新评论,我推荐这篇文章(来源在开头附近链接):
教程:Networking and Bonjour on iPhone
我相信大多数(如果不是全部)文章同样适用于Mac平台,也适用于iPhone平台。