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.

Client.java 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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.Socket;
  9. import java.util.logging.*;
  10. /**
  11. * Builder Class
  12. *
  13. * @author le
  14. */
  15. public class Client extends Transmitter {
  16. private static Logger lg = Logger.getLogger("netz");
  17. private static final int PORT = 35000; //lt. iana port > 2¹⁵
  18. private static final String IP = "127.0.0.1";
  19. public Client(ChatView view) throws IOException {
  20. super(view);
  21. connect();
  22. initIO();
  23. }
  24. @Override
  25. public void connect() throws IOException {
  26. try {
  27. lg.info("Client: Verbindung wird aufgebaut");
  28. socket = new Socket(IP, PORT);
  29. lg.info("Client: Verbindung aufgebaut");
  30. } catch (java.io.InterruptedIOException e) {
  31. lg.warning("Timeout" + "(" + timeout / 1000 + "s)");
  32. }
  33. }
  34. }