fork(1) download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4. import java.net.*;
  5.  
  6. public class Main {
  7. public static final int SERVERPORT = 8888;
  8. public static void main(String[] args) throws IOException {
  9. System.out.println("Starting echo server...");
  10. ServerSocket ss = new ServerSocket(SERVERPORT);
  11. String msg = "";
  12. while (!msg.equals("quit")) {
  13. Socket s = ss.accept();
  14. try {
  15. InputStream is = s.getInputStream();
  16. msg = br.readLine();
  17. while (!msg.equals("quit")) {
  18. System.out.println(msg);
  19. msg = br.readLine();
  20. }
  21. } catch (IOException ioe) {
  22. System.err.println("I/O error: " + ioe.getMessage());
  23. } finally {
  24. try {
  25. s.close();
  26. } catch (IOException ioe) {
  27. assert false;
  28. }
  29. }
  30. }
  31. }
  32. }
Time limit exceeded #stdin #stdout 5s 380288KB
stdin
quit
stdout
Starting echo server...