Posts

Post marked as unsolved
1.3k Views

Can I use a Bonjour name to specify a NWEndpoint?

Hi,I am using Network.framework and I have issues resolving Bonjour addresses...Is it possible to:let host:NWEndpoint.Host = "somehost.local"let port:NWEndpoint.Port = NWEndpoint.Port(MyPort)nwconnection = NWConnection(host: host, port: port, using: .tcp)The problem is that my connection state handler remains in waiting.When I specify the IP address it connects right away - no problem. When I try to connect to a web server on the same machine using Safari, Safari connects right away.Do I need to resolve the IP address of the host using the Bonjour framework before creating a NWEndpoint?What's the best practice establishing a NWNetwork connection to a Bonjour address?Thanks for the support!Best,Michael
Asked
by mjonas.
Last updated .
Post marked as solved
753 Views

Is it possible to temporarily use a socket connection in the background to control an external device via Watch?

Hi,I do have an app that controls an external device through Wifi and a binary socket based protocol. My app so far handles interruptions and disconnects, and it disconnets when entering background and so on. Network.framework - all good.Now I am playing with a watchApp, which works great - IF the app is in forground. I manage coms via WCSession and the app communicates with the device as usual. Very cool actually. Combined with intents a very powerful tool - in theory.The driver however for creating the watchApp is to not require having the iOS App open - and now I am getting lost.In order to support my watch App I would need to at least create a temporary connection on iOS (as long as the watchApp is active) to allow status updates from the device and be able to control it. This does not seem to fit in any of the stated use cases for background execution - and I am not sure if a) I can actuall use Network.framework in a background task? and b) I will get reject at the AppStore if I do so? Reading the documentation it seems only specific system services will be enabled for the different background modes? I would need Network.framework to work with an IP socket?There are certainly ways to reduce the traffic and keep the coms to just what the watch will need - but I am not sure if it is even worth trying?Information would be very much appreciated!Thanks in advance!!
Asked
by mjonas.
Last updated .
Post marked as unsolved
844 Views

Is Network.framework recommended atm?

I find there is low level documentation missing especiall when using swift. E.g. I have trouble finding out when the server end of a socket was closed. The connectionStateUpdateHandler does not seem to get any notification?I also read that some people have issues submitting Apps that use Network.framework?So is Network.framework ready for use? And if so - where would I find information?-mj
Asked
by mjonas.
Last updated .
Post marked as unsolved
310 Views

How do you detect if a tcp NWConnection was closed remotely

Hi,I am toying around with Netfork.framework. It's crazy cool! I do set up a tcp NWListener and successfully create a connection and traffic on a resulting NWConnection object - super easy, never written fewer lines of code for that.What I find a bit strange though is that I am having a hard time detecting when the remote socket was closed. For testing I am using a simple data generator that connects to the port. When I close the generator nothing seems to happen on the NWConnection itself. I have a connectionStateHandler in place and I am watching for errors in the receive completion handler. Receive just does not seem to complete any more and that's it.Did I miss anything in the parameters maybe?-mj
Asked
by mjonas.
Last updated .
Post marked as unsolved
729 Views

Can you figure out the ipaddress of a NWListener

I'm trying to figure out how we could build a tool for our customer service that would allow remote connection to a local device from our service center. The device would be connected by Wifi and is not connected to the Internet, the service center would be reachable by cellular network.Since the devices support ssh access I was hoping to get to a real easy solution by creating a simple port forwarder, which seems to be a no-brainer using Network.framework. The app would connect to the port of the device, open a Listener and advertise the IP address to our service center through a TLS connection.The approach would avoid that I have to deal with ssh in any way and a regular ssh-terminal app could be used to connect to the device - the only caveat being to figure out the NWListeners local endpoint's ipaddress in the cellular network...Any clue? Is this even possible?
Asked
by mjonas.
Last updated .