代码如下:
//Server.java
import java.awt.*;
import java.net.*;
import java.io.*;
public class Server extends Thread {
ServerSocket skt;
Socket Client[]=new Socket[10];;
Socket Client1=null;
int i = 0;
TextArea in;
int port,k=0,l=0;
//BufferedReader theInputStream;
PrintStream theOutputStream;
//String readin;
Face chat;
public Server(int port, Face chat) {
try {
this.port = port;
skt = new ServerSocket(port);
this.chat = chat;
} catch (IOException e) {
chat.ta.append(e.toString());
}
}
public void run() {
chat.ta.append(" 等待连线 ......");
while (true) {
//System.out.print(""+i+"");
try {
Client[k] = skt.accept(); /* 接收客户连接 */