SwiftSocket
SwiftSocket copied to clipboard
localhost and 127.0.0.1 not working
let server = TCPServer(address: "127.0.0.1", port: 8080) and let server = TCPServer(address: "localhost", port: 8080) are not working.
If I use the actual IP of the device then it works: let server = TCPServer(address: "192.168.1.101", port: 8080).
There is no error, but the port is not open.
Why is that?
I experienced this as well. I'm glad I found your workaround though.
Hopefully some can fix the problem. Please note that it is not good idea to hardcode the ip address! Or you should ask from the code the ip -(I am not sure how it is possible or if it is possible), or you need to be sure that the device always gets the same ip from the router (dhcp settings)!
I am also experiencing this, but strangely with the same code that used to work about a month ago. I have a feeling this comes from an Xcode/OSx update..
EDIT: Confirmed, XCode 10 forces the project to be code signed, which for some reason brakes SwiftSocket. After downgrading to XCode 9.4.1, I had to change back in Build Settings -> Code Signing Identity -> Don't Sign + Clean + Build.
For me is working TCPServer(address: "127.0.0.1", port: 8080) but then I then I can connect only from localhost :D