import java.io.*; import java.net.*; import java.awt.*; class Puks extends Thread { Socket socket; DataOutputStream outputs; DataInputStream inputs; String serverName; int serverPort; String chatChannel; TextArea textDisplayArea; public Puks( String _serverName, int _serverPort, String _chatChannel, TextArea _textDisplayArea ) { serverName = _serverName; serverPort = _serverPort; chatChannel = _chatChannel; textDisplayArea = _textDisplayArea; } public void run() { try { socket = new Socket(serverName,serverPort); outputs = new DataOutputStream(socket.getOutputStream()); inputs = new DataInputStream(socket.getInputStream()); String message; this.write("CHANNEL " + chatChannel); this.write("HISTORY"); boolean go = true; while (go) { message = inputs.readLine(); if ( message == null ) { go = false; } else { textDisplayArea.appendText(message+"\n"); } } } catch (Exception e) { textDisplayArea.appendText("CONNECTION ERROR :"+"\n"); textDisplayArea.appendText(e.getMessage()+"\n"); } } void write( String mess ) { try { outputs.writeBytes(mess+"\n"); outputs.flush (); } catch (Exception e) { textDisplayArea.appendText("OUTPUT ERROR :"+"\n"); textDisplayArea.appendText(e.getMessage()+"\n"); } } }