SwiftSocket icon indicating copy to clipboard operation
SwiftSocket copied to clipboard

localhost and 127.0.0.1 not working

Open szotyi007 opened this issue 7 years ago • 4 comments
trafficstars

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?

szotyi007 avatar Sep 16 '18 15:09 szotyi007

I experienced this as well. I'm glad I found your workaround though.

mostlyjason avatar Sep 24 '18 15:09 mostlyjason

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)!

szotyi007 avatar Sep 24 '18 15:09 szotyi007

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.

raduvarga avatar Oct 01 '18 08:10 raduvarga

For me is working TCPServer(address: "127.0.0.1", port: 8080) but then I then I can connect only from localhost :D

gbread avatar Jan 21 '20 02:01 gbread