@Frameworks Engineer Your guidance on above queries from @nikhil0n1 will help
Post
Replies
Boosts
Views
Activity
In some cases thats the right thing to do, but in a lot of cases it’s a mistake (for example, using it to find the ‘primary’ IP address as part of an implementation of some protocol layered on top of UDP).
@eskimo In those cases, what should one use?
Try if below works:
To find the IP address of the Apple Watch Simulator so you can communicate with an application running in the simulator, you need to follow a few steps. Since the simulator itself doesn't have a separate IP address (it runs within the context of your Mac), you'll need to identify the IP address of your Mac and use the appropriate network configurations to access the application running on the simulator. Here's how you can do it:
Find the IP Address of Your Mac:
Open the Terminal application on your Mac.
Type the following command and press Enter:
bash
Copy code
ifconfig
Look for the network interface you're using (typically en0 for Wi-Fi). The IP address will be listed under inet. It might look something like 192.168.1.10.
Port Forwarding:
You need to set up port forwarding from your Mac to the simulator. This involves mapping a port on your Mac to a port on the simulator. You can use a tool like socat to achieve this.
Install socat if you don't already have it. You can use Homebrew to install it:
bash
Copy code
brew install socat
Set up port forwarding with socat:
bash
Copy code
socat TCP-LISTEN:<PORT_ON_MAC>,reuseaddr,fork TCP:127.0.0.1:<PORT_ON_SIMULATOR>
Replace <PORT_ON_MAC> with the port number you want to use on your Mac and <PORT_ON_SIMULATOR> with the port number your application is using in the simulator.
Access the Application:
Once port forwarding is set up, you can access the application running on the Apple Watch Simulator using your Mac's IP address and the forwarded port. For example, if your Mac's IP address is 192.168.1.10 and you forwarded port 8080 to 5000, you can access it via 192.168.1.10:8080.
Ensure Proper Network Configurations:
Make sure your network firewall settings allow connections to the port you've chosen.
If you encounter issues, double-check that the application running on the simulator is correctly listening on the specified port.
By following these steps, you should be able to communicate with the application running in the Apple Watch Simulator from outside using your Mac's IP address and the specified port.
If you run your command line client application also from the same mac, then you may not need port forwarding and directly using 127.0.0.1:<PORT_ON_SIMULATOR> might work.
@DTS Engineer The question really here is when one opens two NWListeners with ipOptions.version = .v6 and .v4 respectively and we can confirm that underlying sockets created are of type udp4 and udp6 (and not udp46) respectively. Then if standard says, one should be able to bind a socket to same port if your transport & ip protocol are different, then why in this case, we cannot do the same?