socket bind() failing in cocoa app but not in commandline tool

Call to bind() is failing in my Cocoa app project but not in a commandline tool project (with same exact networking code).

  • No sandbox
  • Catalina (with SIP disabled, but solution will need to work on machines with SIP enabled)
  • App transport settings wide open (this is a client-only setting though AFAIK)
  • sandboxd says "deny(1) network-bind*:32323"

When I copy the code to a commandline project, it works.

1 - If the app is not sandboxed, why is there a sandbox error in the log?

2 - Is there something else I need to add to Info.plist for binding to a network port (and other related server functionality) from a Cocoa app?

It’s hard to think of any way you’d could get this error in a non-sandboxed app, so I suspect that your app is sandboxed even though you think it isn’t. To confirm this, run Activity Monitor, bring up the process list (Window > Activity Monitor), and look in the Sandbox column (you may need to enable this by control clicking on the table header).

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

socket bind() failing in cocoa app but not in commandline tool
 
 
Q