Could you tell me how you can create a socket server for communication socket-client (phone on Android) in Java via the global Internet? At the moment I have a socket client and a server on Apache.

    1 answer 1

    Of course, I may not understand you correctly, but connect to the server so Socket s = new Socket(ADDRESS, PORT); where ADDRESS is the ip of the server, and PORT, respectively, its port.

    On the server side should be this

     InetAddress address = InetAddress.getByName(ADDRESS); ServerSocket serverSocket = new ServerSocket(PORT, 0, address); 

    In my case, the server-side ADDRESS was the string "localhost".

    • I did it, but I didn’t succeed, the client doesn’t connect to the server. I save the file with the Java extension and run it via the command line, can I launch it incorrectly? server up to this point :)) - user208881
    • Download some IDE and try to do something through it. And then, as I understand it, you do not have it. - exStas