Swift Socket not resolving dns in ios 11
This code works till iOS 10. however it stopped working when I upgraded to iOS 11. I debugged and found the problem in ytcpsocket_connect.c gethostbyname() function is unable to resolve the DNS and the library always returns the queryFailed error. Please advise.
var client = TCPClient(address: "device.abc.com", port: Int32(5001))
switch client.connect(timeout: 5) {
case .success:
print("connected")
case .failure(let error):
print("Socker Error Reason - \(error)")
}
Same issue .. my app rejected bcz unable to resolve the ipv6 address
Are there any updates to this issue? I have the exact same problem that no matter what address I put into the TCPClient, connecting always returns the queryFailed error.
I confirmed that mine was also acting up in the file "ytcpsocket.c" (Pods/SwiftSocket/ytcpsocket.c) in the function "ytcpsocket_connect". The issue is that after the call hp = gethostbyname(host) is executed, hp is always null, and thus returns -1.
Please, if someone has figured out how to move passed this, any help would be much appreciated!
I had to use the IP itself to connect. DNS name didn't work.
@abbasqamar did you get any solution to connect via ipv6 address ? It gives me query failed error.