java - What is localhost for Android? -
What is the 'localhost' address for Android devices?
I am testing a program using the client server on the same app.
Neither works for This returns: Unable to resolve the host What is the best way to use a local host? UPDATE Thanks for all comments: Communicate on TCP, which is a low level protocol compared to HTTP. When you have a socket communication If you are identifying, use the server's bare name (for example, "localhost") or a dotted quad (for example "192.168.0.100"). T includes http: // or any other plan . If I understand the question correctly and aim to open the socket by the same machine (phone) with the target, then you use to get the "loopback" interface, which is equivalent to using the local host. SERVER_IP = "http: // localhost" and
"http://127.0.0.1"
InetAddress serverAddr = InetAddress.getByName (SERVER_IP); Socket = new socket (serveradder, serverport);
"http: // localhost" : Hostname with Android No address is associated
"http: // localhost" / code> is indestructible right
"localhost" or
"127.0.0.1" or
"127.0.0.2" , but I hope the best solution is to answer the answer.
InetAddress serverAddr = InetAddress.getByName (empty );
Comments
Post a Comment