GCDAsyncSocket 填坑

GCDAsyncSocket 监听绑定

NSError *error = nil;
[self.server acceptOnPort:self.portNumber.intValue error:&error];
if (error) {
  NSLog(@"%@", error);
}

报错

mac Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted" UserInfo={NSLocalizedDescription=Operation not permitted, NSLocalizedFailureReason=Error in bind() function}

终端监听 端口12345 Connection refused

~ telnet 127.0.0.1 12345
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
telnet: Unable to connect to remote host

最佳答案

生成的Xcode授权阻止了绑定
MacService.entitlements 将这些值改为false现在绑定工作





    com.apple.security.app-sandbox
    
    com.apple.security.files.user-selected.read-only
    


你可能感兴趣的:(GCDAsyncSocket 填坑)