new Server(port);
}
// End of the main
} // End of
Server class
//以下定义了Connection
类,它是用来处理与客户机的所有通信的线程。
class Connection extends Thread
{
protected Socket client;
protected DataInputStream in;
protected PrintStream out;
// 初始化通信流并启动线程
public Connection(Socket client_socket)
{
client = client_socket;
try
{
in = new DataInputStream(client.getinputStream());
out = new PrintStream(client.getOutputStream());
}
catch(IOException e)
{
try client.close();
catch(IOException e2);
System.err.println("Exception while getting socket
streram: " e);
Return;
}
this.start;
}
延伸阅读
文章来源于领测软件测试网 https://www.ltesting.net/