You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Server.java 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
  3. * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template
  4. */
  5. package ChatProgramm.model;
  6. import ChatProgramm.view.ChatView;
  7. import java.io.IOException;
  8. import java.net.ServerSocket;
  9. import java.util.logging.*;
  10. /**
  11. * Builder Class
  12. * @author le
  13. */
  14. public class Server extends Transmitter
  15. {
  16. private static Logger lg = Logger.getLogger("netz");
  17. private static final int PORT = 35000; //lt. iana port > 2¹⁵
  18. public void connect() throws IOException
  19. {
  20. try
  21. {
  22. ServerSocket sSocket = new ServerSocket(PORT);
  23. sSocket.setSoTimeout(timeout);
  24. lg.info("Server: warte auf Verbindung");
  25. socket = sSocket.accept();
  26. lg.info("Server: Verbindung akzeptiert");
  27. }
  28. catch ( java.io.InterruptedIOException e )
  29. {
  30. lg.warning("Timeout"+"("+timeout/1000+"s)");
  31. }
  32. }
  33. public Server(ChatView view) throws IOException {
  34. super(view);
  35. connect();
  36. initIO();
  37. }
  38. }