I am stuck at stage #wy1 . not able to progress . not sure why .
here are the logs .
Here is the code .
import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;
public class Main {
public static void main(String[] args){
// You can use print statements as follows for debugging, they'll be visible when running tests.
System.out.println("Logs from your program will appear here!");
// Uncomment this block to pass the first stage
ServerSocket serverSocket = null;
Socket clientSocket = null;
int port = 6379;
try {
serverSocket = new ServerSocket(port);
// Since the tester restarts your program quite often, setting SO_REUSEADDR
// ensures that we don't run into 'Address already in use' errors
serverSocket.setReuseAddress(true);
// Wait for connection from client.
clientSocket = serverSocket.accept();
process(clientSocket);
} catch (IOException e) {
System.out.println("IOException: " + e.getMessage());
} finally {
try {
if (clientSocket != null) {
clientSocket.close();
}
} catch (IOException e) {
System.out.println("IOException: " + e.getMessage());
}
}
}
private static void process(Socket clientSocket) {
try (BufferedReader reader = new BufferedReader(
new InputStreamReader(clientSocket.getInputStream()));
BufferedWriter writer = new BufferedWriter(
new OutputStreamWriter(clientSocket.getOutputStream()));) {
String content;
while ((content = reader.readLine()) != null) {
if ("ping".equalsIgnoreCase(content)) {
writer.write("+PONG\r\n");
writer.flush();
break;
} else if ("eof".equalsIgnoreCase(content)) {
break;
}
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}