How to organize the interaction between java server and android client in your local network?
The bottom line is this: is installed on the computer application that acts as a server for the local network. The client application on the Android device must connect to the same local network and pokidajut to the server some data. Everything seemed to be fine - the server works fine, but Android doesn't want to connect according to the diagram new Socket("localhost", port); For the test wrote the client on your PC - everything works in this ad. I understand that I need to do something on the part of Android and to understand this, first thought - perhaps we should specify more explicitly the IP, but I'm not sure that's the problem, of course. If you suggest a solution to the problem and how to communicate in the local network - I would be very grateful.
PS it is understood that "server" on a PC application that can supply any person and interact with it from your phone.
PS.s when you explicitly specify the ip address of konekt's going on, but the question again is that every new computer it your. My idea - display PC IP, which must be entered in the mobile client for konekta. Don't really like this solution, I would like to hear more educated decisions
Of course, to localhost, the Android will not connect! Since localhost to the address 127.0.0.1, which is responsible for local (loopback) interface on your device. This address is on every device or computer that is created to network programs within the operating system.
In other words, You need to set the connection ip address of the computer on which spouse server.
Well, exchange is fine, the http/https Protocol, and to connect easier and your Protocol should not be written, many frameworks and libraries are there for this. On the client side is fine httpok, server - springboot, jooby, spartjava and a couple dozen others, including tomcat and jetty.