newThreadEchoHandler(incoming,i).start();
i++;
}
}
catch(Exceptione)
{System.out.println(e);}
}
}
//客户端通信小应用程序Echo.java
importjava.io.*;
importjava.net.*;
importjava.awt.*;
importjava.applet.*;
publicclassEchoextendsApplet
{
TextAreata;
SocketechoSocket;
DataOutputStreamos;
DataInputStreamis;
StringLine;
publicvoidinit()
{
setBackground(Color.white);
ta=newTextArea(5,80);
ta.setEditable(false);
add(ta);
try
{echoSocket=newSocket("10.102.4.41",1111);}//与服务器建立连接
catch(IOExceptione)
{System.out.println("error");}
}
publicvoidst(Stringstri)//发送字符串的方法
{
try
{DataOutputStreamos=newDataOutputStream(echoSocket.getOutputStream());
DataInputStreamis=newDataInputStream(echoSocket.getInputStream());
os.writeUTF(""+stri);//向服务器输送string
os.flush();
}
catch(IOExceptione)
{System.out.println("error:"+e);}
}
publicStringst1()//接收字符串的方法
{

