diff --git a/src/main/java/ChatClient.java b/src/main/java/ChatClient.java index c4f2737..3627c91 100644 --- a/src/main/java/ChatClient.java +++ b/src/main/java/ChatClient.java @@ -1,12 +1,31 @@ import javax.swing.*; +import java.io.IOException; +import java.net.Socket; public class ChatClient { private String address; - public ChatClient() { + private int port; + private Socket connectionToServer; + + public ChatClient(int port) { + this.port = port; address = JOptionPane.showInputDialog("bitte IP-Adresse"); + + if (address != null) { + receiveMessages(); + } + } + + private void receiveMessages() { + try { + connectionToServer = new Socket(address, port); + } catch (IOException e) { + JOptionPane.showMessageDialog(null, "Verbindung zum Server \"" + address + "\" fehlgeschlagen."); + } } public static void main(String[] args) { - new ChatClient(); + new ChatClient(3141); + } } \ No newline at end of file