Opening TCP listening sockets is not an operation protected by LNP. See LNP FAQ-2.
Yeah I just read that on the FAQ you sent to me, which I find strange considering that listening for TCP on the local network technically accesses the local network.
Sending UDP broadcast packets should trigger LNP, and it certainly did the last time I tried it [1].
That part is surprising because according the FAQ you sent me I should be disallowed to do this completely because I didn't pay for the 100$ a year and UDP broadcast requires a special entitlement but in my case it requires nothing the only flags I've enabled in my Info.plist are:
- "Supports Document Browser" -> Internet said this was required to support the Files app on iOS (linked with the second permission).
- "Supports opening documents in place" -> Allows editing of all configuration files and lua scripts directly on the iPhone and allows viewing core application logs on the iPhone.
- "Application supports iTunes file sharing" -> Allows my mac Finder to put lua files and other configuration files directly in the application documents directory.
Are you sure those packets are going out on the ‘wire’?
Well I'm sure these packets are sent otherwise how could I see the UDP packet from the client app running on my Mac?
Let me give you a part of the low-level network code so you can see by yourself (the actual code is in Rust but I tried to translate it to C):
pub const DEFAULT_PORT: u16 = 4026;
let packet = [/* some bytes here */];
let socket = UdpSocket::unbounded(Domain::IpV4).unwrap();
socket.set_broadcast(true).unwrap();
if let Err(e) = self.socket.send_to(&packet, (Ipv4Addr::BROADCAST, DEFAULT_PORT)) {
eprintln!("Failed to send broadcast auto-discover packet: {}", e);
}
Here is my translation in C (using BSD names):
#include <sys/socket.h>
#include <netinet/in.h>
#include <string.h>
#include <stdio.h>
#define DEFAULT_PORT 4026
char packet[] = {0, 1, 3}; //This is just for example; the actual packet is more complicated.
int s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
int flag = 1;
setsockopt(s, SOL_SOCKET, SO_BROADCAST, &flag, sizeof(int));
struct sockaddr_in addr;
memset(&addr, 0, sizeof(struct sockaddr_in));
addr.sin_family = AF_INET;
addr.sin_port = (in_port_t)htons(DEFAULT_PORT);
addr.sin_addr.s_addr = htonl(INADDR_BROADCAST);
if (sendto(s, &packet, 3, 0, (struct sockaddr *)&addr, sizeof(struct sockaddr_in)) < 0)
fprintf(stderr, "Failed to send broadcast auto-discover packet");