[iOS simulator] : nw_connection_send getting error "nw_write_request_report [C1] Send failed with error "Permission denied""

Hi,

I'm doing a local network discovery apps.

And I had already added related permission description in info.plist.

My apps works well in my iPhone, but running in iOS simulator, it did't show to ask the local network permission.

After I calling nw_connection_send, I got the error as title.

Does iOS simulator didn't support permission simulation ?

Xcode version : 12.4

Thanks

but running in iOS simulator, it did't show to ask the local network permission.

Right, the simulator will not show the local network permission prompt, as it is technically running on the network stack from the macOS machine.

As to what is happening in your title, you mentioned that you were doing local network discovery. Can you share any more code or information on what you are doing here?



Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com
Hi Matt,

Thanks for your response.
  • Create an udp connection on broadcast address. I'm using Network framework.

  • In button click callback, I called _SearchSend() to send an UDP packet to the broadcast address.

  • (IBAction)ButtonSearch:(id)sender {

    _SearchSend();

}

int _SearchSend(void)

{

    char buf[128] = {0};

    struct in_addr addr;

    unsigned long index = 0;

    addr.s_addr = OSSwapInt32(_myIPaddr);

    memcpy(buf, inet_ntoa(addr), strlen(inet_ntoa(addr)));

    index = strlen(inet_ntoa(addr));

    index++;

    buf[index] = '@';

    index++;

    memcpy(&buf[index], [_myDevName cStringUsingEncoding:NSASCIIStringEncoding], strlen([_myDevName cStringUsingEncoding:NSASCIIStringEncoding]));

    dispatch_data_t data = dispatch_data_create(&buf[0], sizeof(buf), dispatch_get_main_queue(), DISPATCH_DATA_DESTRUCTOR_DEFAULT);

    nw_connection_send(_SearchConn, data, NW_CONNECTION_DEFAULT_MESSAGE_CONTEXT, true, ^(nw_error_t  _Nullable error) {

        printf("search send block \n");

    });

    return 0;

}

3. I found the UDP packet didn't be sent, and console print out below error logs:
nw_write_request_report [C1] Send failed with error "Permission denied"

Thanks
Thanks for the extra bit of information here about sending / receiving broadcasts. It's hard to tell what's specifically going on with your code without more context. However, I can say that you should apply for the Multicast Entitlement for sending / receiving broadcasts in the future here. (Note, read the Important Section here)


Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com
Hi Matt,

Appreciate for your help, I will learn your suggestion.

Thanks
[iOS simulator] : nw_connection_send getting error "nw_write_request_report [C1] Send failed with error "Permission denied""
 
 
Q