Reachability.swift
Reachability.swift copied to clipboard
'hostname' with a port, possible?
First off, thanks for the work.
Just getting started here, and all seems okay except when I am trying to keep track of a specific server URL (on a port) via hostname parameter. I am keeping track for 2 Reachability's, one for the device's network (i.e "let networkReachability = Reachability()!") and also a specific server URL (see below). The issue is on the server URL attempt, which has a specific DNS with a port number over HTTPS. Noticed that a regular HTTPS or HTTP hostname string (w/o port) will work but not with a port added.
Format attempted to use (didn't work): let filesServerReachability = Reachability(hostname: "https://files.ServerURL.com:6060")!
This does work though: let hostnameReachability = Reachability(hostname: "https://www.msn.com")!
Thanks!
BTW, it works only for hosts with www
. For example, for "https://msn.com" it doesn't work
Related to this, I was hoping that the 'hostname' parameter within one of the convenience initializers is also exposed as a getter/setter property that can be dynamically changed (to avoid having to declare and init a new Reachability object just for monitoring a single URL).
I think the dependence on SCNetworkReachability will prevent this though
BTW, I'm also dependent on specifying my own port for https.
So is there no way to use this framework if we want to test Reachability of an internal server; ex. "https://internalserver.company.com"? Or we just have to put "www" in front of it?
I had issues too, but it turns out you just have to remove https://
. Just try if you can ping a url first in Terminal, this doesn't work either with https://
in front of the url.
I don't know about the port numbers t.b.h.