Advertisement
Guest User

Untitled

a guest
May 24th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. package chatSystem;
  2.  
  3. import java.io.IOException;
  4. import java.net.*;
  5.  
  6. public class ServerApplication
  7. {
  8. public static void main(String args[])
  9. {
  10. ServerSocket server = null;
  11. Socket socket = null;
  12. ClientDescriptor client = null;
  13. ConnectionProxy connection = null;
  14. MessageBoard mb = new MessageBoard();
  15. try
  16. {
  17. server = new ServerSocket(1300,5);
  18. while(true)
  19. {
  20. System.out.println("Socket accept()...");
  21. socket = server.accept();
  22. connection = new ConnectionProxy(socket);
  23. client = new ClientDescriptor();
  24. connection.addConsumer(client);
  25. client.addConsumer(mb);
  26. mb.addConsumer(connection);
  27. connection.start();
  28. }
  29. }
  30. catch (IOException e) {e.printStackTrace();}
  31. finally
  32. {
  33. if (socket != null)
  34. {
  35. try {socket.close();}
  36. catch(IOException e) {e.printStackTrace();}
  37. }
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement