|
|
@ -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); |
|
|
|
|
|
|
|
} |
|
|
|
} |