?? server_socket.java
字號:
import java.net.*;
import java.util.*;
import java.io.*;
public class Server_socket extends Thread
{
private ServerSocket scoket;
private History history_info=new History();
private Vector clientnum=new Vector();
public void run()
{
try
{
scoket=new ServerSocket(2222);
while(true)
{
Socket sc=scoket.accept();
clientnum.addElement(sc);
System.out.println(sc);
Client_socket ddd=new Client_socket(sc,history_info);
ddd.start();
}
}
catch(Exception e)
{
System.out.println(3);
System.out.println(e);
}
}
public void stop_server()
{
try
{
scoket.close();
Enumeration sc=clientnum.elements();
while(sc.hasMoreElements())
{
Socket sc1=(Socket)sc.nextElement();
sc1.close();
System.out.println("some client is rejected");
}
clientnum.clear();
}
catch(Exception e)
{
System.out.println(5);
System.out.println(e);
}
}
};
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -