fork download
  1. package chat;
  2.  
  3. import java.net.*;
  4. import java.io.*;
  5. import java.util.*;
  6.  
  7. public class Server_Side {
  8.  
  9. private ServerSocket ss;
  10. private Hashtable outputSteams = new Hashtable();
  11.  
  12. public Server_Side(int port) throws IOException {
  13. listen(port);
  14. // ServerSocket server = new ServerSocket(5000);
  15. // while(true) {
  16. // Socket newSocket = server.accept();
  17. // }
  18.  
  19. }
  20. private void listen(int port) throws IOException {
  21.  
  22. ServerSocket ss = new ServerSocket(5000);
  23. System.out.println("Connecting! ");
  24.  
  25. while (true) {
  26.  
  27. Socket s = ss.accept();
  28. System.out.println("Connected! ");
  29. DataOutputStream dout = new DataOutputStream(s.getOutputStream());
  30. outputStreams(s, dout);
  31. new ServerThread(this, s);
  32.  
  33. }
  34.  
  35. }
  36.  
  37. Enumeration getOutputStream(){
  38. return outputSteams.elements();
  39. }
  40. void sendToAll(String message){
  41. synchronized (outputSteams){
  42. for (Enumeration e = getOutputStream(); e.hasMoreElements(); ){
  43. DataOutputStream dout = (DataOutputStream)e.nextElement();
  44. try {
  45. dout.writeUTF(message);
  46. } catch (IOException ie) {System.out.println( ie);}
  47.  
  48. }
  49. }
  50.  
  51. }
  52. void removeConnection( Socket s ){
  53. synchronized ( outputSteams ){
  54. System.out.println("Removing Connection" + s);
  55. outputSteams.remove(s);
  56. try {
  57. s.close();
  58. }catch (IOException ie){
  59. System.out.println("Error Closing " +s);
  60. ie.printStackTrace();
  61. }
  62.  
  63. }
  64. }
  65.  
  66.  
  67. public static void main(String[] args) throws Exception {
  68.  
  69. int port = Integer.parseInt(args[0]);
  70. new Server_Side(port);
  71.  
  72. }
  73.  
  74. private void outputStreams(Socket s, DataOutputStream dout) {
  75.  
  76. }
  77.  
  78.  
  79.  
  80. }
  81.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:7: error: class Server_Side is public, should be declared in a file named Server_Side.java
public class Server_Side {
       ^
Main.java:31: error: cannot find symbol
            new ServerThread(this, s);
                ^
  symbol:   class ServerThread
  location: class Server_Side
2 errors
stdout
Standard output is empty