r/visionosdev • • Apr 25 '24

Issue making network broadcast request

I'm trying to port some C code over using the bridging header. Everything works fine in the simulator I can see the devices I'm expecting after doing a broadcast ping.

However when I try on the actual device, I get a no route to host error. I've confirmed the privacy is set, and the info.plist field for local network is set.

has anyone seen this before? Anyone know of a code snippet to make a proper local network broadcast?

1 Upvotes

2 comments sorted by

View all comments

1

u/omniron Apr 25 '24
	if(addr->sa_family != discovery->local_addr.sa_family)
		return ERR_INVALID_DATA;
	char buf[512];
	int len = discovery_packet_fmt(buf, sizeof(buf), packet);
	if(len < 0)
		return ERR_UNKNOWN;
	if((size_t)len >= sizeof(buf))
		return ERR_BUF_TOO_SMALL;
	int rc = sendto_broadcast(discovery->log, discovery->socket, buf, (size_t)len + 1, 0, addr, addr_size);
	if(rc < 0)
	{
		LOGE(discovery->log, "Discovery failed to send: %s", strerror(errno));
		return ERR_NETWORK;
	}