import java.io.*;
import java.applet.Applet;
import java.net.*;
import javax.swing.*;
import java.awt.*;
import java.util.*;
public class ClientApplet extends Applet {
public static TextArea chat;
public void init() {
chat = new TextArea(10,40);
add(chat);
chat.append("Hey!");
Socket s = null;
try {
s = new Socket(getParameter("host"), Integer.valueOf(getParameter("port")));
//s = new Socket("localhost", 4444);
InputStream in = s.getInputStream();
int buf = -1;
while ((buf = in.read()) != '.') {
System.out.print((char)buf);
}
}catch(Exception e) {
e.printStackTrace();
}
finally {
try {
s.close();
} catch(IOException e)
{ }
}
}
}
|