Note that there are some explanatory texts on larger screens.

plurals
  1. POjava server socket in cloud server
    primarykey
    data
    text
    <p>So I have two java classes for socket server and client as follows:</p> <p><strong>For the server:</strong></p> <pre><code>System.out.println("Server started:"); ServerSocket server = new ServerSocket(1935, 0, InetAddress.getByName("localhost")); Socket connection = new Socket(); while(active){ connection = server.accept(); printTimeStamp(); InputStream in = connection.getInputStream(); while(in.available() == 0){ //waiting till message is complete } MessageDecode(in); } </code></pre> <p>MessageDecode is just an internal method that reads the input streams and stores it somewhere</p> <p><strong>for the client</strong></p> <pre><code>Socket connectionSocket = new Socket(); InetAddress address = InetAddress.getByName("THE_CLOUD_SERVER_IP"); SocketAddress sAddress = new InetSocketAddress(address, 1935); connectionSocket.setKeepAlive(true); connectionSocket.setTcpNoDelay(true); connectionSocket.connect(sAddress, 2000); OutputStream os = connectionSocket.getOutputStream(); os.write("HELLO SERVER".getBytes()); os.close(); System.out.println("sent"); </code></pre> <p>when I run both on a localhost it works like a charm, but when I run the class into the cloud server, I get timout exception <code>java.net.SocketTimeoutException: connect timed out</code></p> <p>even when the por is listening, I know its listening because when I run the app, and do a netstat -anp I get:</p> <pre><code>tcp 0 0 127.0.0.1:1935 0.0.0.0:* LISTEN PID/java </code></pre> <p>can someone give me a clue on how to solve this? your help is must appreciated. Thanks (._.')</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload