Beruflich Dokumente
Kultur Dokumente
try {
ServerSocket ss= new ServerSocket(8000);
echoSocket = ss.accept();
out = new PrintWriter(echoSocket.getOutputStream(), true);
in = new BufferedReader(new InputStreamReader(
echoSocket.getInputStream()));
} catch (UnknownHostException e) {
System.err.println("Don't know about host.");
System.exit(1);
}
catch (Exception e) {
System.err.println("error 1");
System.exit(1);
}
try{
do{
msg=in.readLine();
t1.append(msg+'\n');
} while (!msg.equals("quit")) ;
System.exit(1);
} catch (IOException e) {
System.err.println("Couldn't get I/O.");
System.exit(1);
}
catch (Exception e) {
System.err.println("error 2");
System.exit(1);
}
}///////////////////end of constructor
public void actionPerformed(ActionEvent event)
{
String userInput;
try {
userInput = t2.getText();
out.println(userInput);
t2.setText("");
t1.append("Sent:"+userInput+'\n');
} catch (Exception e) {
System.err.println("Couldn't get I/O.");
System.exit(1);
}
try {
echoSocket = new Socket("localhost", 8000);
out = new PrintWriter(echoSocket.getOutputStream(), true);
in = new BufferedReader(new InputStreamReader(
echoSocket.getInputStream()));
} catch (UnknownHostException e) {
System.err.println("Don't know about host.");
System.exit(1);
} catch (Exception e) {
System.err.println("error in client object ");
System.exit(1);
}
try{
do{
msg=in.readLine();
//if(msg==null) continue;
t1.append("Server:"+msg+'\n');
} while (!msg.equals("quit")) ;
System.exit(1);
} catch (IOException e) {
System.err.println("Couldn't get I/O for " + "the connection to: taranis.");
System.exit(1);
}
catch (Exception e) {
System.err.println("error 2");
System.exit(1);
}
}// end of constructor
OUTPUT