TCP connection between iOS devices

I try to connect 2 iOS devices using TCPSocket to exchange some data.
Which port should I use to Listen?

As your apps won’t run as administrator (I presume), you can’t use ports below 1025.
Other than that, avoid ordinary ports as they may already be listening or used.

I’m not sure how you can configure the iOS firewall to allow ports, however.

In previous versions Xojo.Net.TCPSocket didn’t had a Listen method. The new TCPSocket has one. So I thought we can use this.
If I activate this method and check the LocalAddress, I don’t get the ip-address of the iOS-device but an address in a for me unknown range.

@Herman_Dubach
Could you show us what IP address you got? That might help us figure out what’s going on.

Hi Greg, 10.84.173.104, instead in a range 192.168…

Are you sure you’re connected to WiFi? 10-dot IP addresses are reserved for private networks, and this may be the actual IP address you’ve been assigned by your mobile carrier.

Yes I am absolutely sure. The device has an address in the range 192…

FWIW, So is 192.168.x.x.

That said, you should try iterating through System.NetworkInterfaces and see if there’s more than one.

1 Like

Right. Just saying that it’s possible their carrier has assigned them that address due to the number of supported addresses, and they may not be using the correct NIC.

That said, you should try iterating through System.NetworkInterfaces and see if there’s more than one.

On iOS ?

system.networkinterfaces doesn’t exist on iOS!

yes that’s why i’m asking…

Doh! Sorry. Typing from my couch!

Brand new in MBS plugins 21.1 are two classes you may be able to exploit here. Brief mention of them in the new video where there is a demo using macOS instead of iOS but the classes are marked as iOS compatible too.

See NSNetServiceMBS and NSNetServiceBrowserMBS and the example projects linked on those pages (or in plugin’s examples folder). While the examples are probably desktop oriented, I think the same syntax applies to iOS.