public class TestServer
{
public static void main(String[] args)
{
try {
InputStream in = null;
OutputStream out = null;
ServerSocket ss = new ServerSocket(5555);
while(true)
{
Socket s1 = ss.accept();
System.out.println(s1.getPort() + " a Client!");
in = s1.getInputStream();
out = s1.getOutputStream();
InputStreamReader isr = new InputStreamReader(in);
BufferedReader isread = new BufferedReader(isr);
OutputStreamWriter osr = new OutputStreamWriter(out);
PrintWriter pw = new PrintWriter(osr);
InputStreamReader str = new InputStreamReader(System.in);
BufferedReader str1 = new BufferedReader(str); //建立2个管道
public class TestClient
{
public static void main(String[] args)
{
try {
InputStream in = null;
OutputStream out = null;
Socket s1 = new Socket("127.0.0.1",5555);
in = s1.getInputStream();
out = s1.getOutputStream();
InputStreamReader isr = new InputStreamReader(in);
BufferedReader isread = new BufferedReader(isr);
OutputStreamWriter osr = new OutputStreamWriter(out);
PrintWriter pw = new PrintWriter(osr);
InputStreamReader str = new InputStreamReader(System.in);
BufferedReader str1 = new BufferedReader(str);