📄 chatserverex.java
字号:
import java.net.*;
import java.io.*;
import java.util.*;
//***ChatServerEx 努贰胶 汲拌************************************************************
public class ChatServerEx{
ServerSocket server; //辑滚 家南
final static int port=6000; //器飘 锅龋
Socket child; //努扼捞攫飘客 烹脚窍扁 困茄 家南
//++货酚霸 眠啊等 函荐+++++++++++++++++++++++++++++++++++
//胶饭靛 埃狼 沥焊甫 傍蜡且 HashMap : key绰 酒捞叼捞绊 value绰 免仿 胶飘覆
HashMap<String, ObjectOutputStream> hm;
//辑滚 家南 积己, 单捞磐 价荐脚 窍扁 困秦辑 胶饭靛(ChatServerThread)按眉 积己
public ChatServerEx( ) {
try{
server = new ServerSocket(port); //器飘甫 瘤沥秦辑 辑滚 家南 积己
}catch(Exception e){ //辑滚 家南 积己俊 角菩窍搁
e.printStackTrace(); //俊矾 皋矫瘤甫 免仿窍绊
System.exit(0); //橇肺弊伐阑 辆丰茄促.
}
System.out.println("**** 盲泼 辑滚*****");
System.out.println("辑滚绰 努扼捞攫飘 家南狼 立加 夸没阑 扁促府绊 乐澜");
//+++胶饭靛 埃狼 沥焊甫 傍蜡且 HashMap 按眉 积己+++++++++
hm = new HashMap<String, ObjectOutputStream>( );
while(true){ //努扼捞攫飘狼 立加阑 亲惑 罐酒甸老 荐 乐档废 公茄风橇甫 倒覆
try{
child = server.accept( ); //努扼捞攫飘狼 立加 夸没阑 罐酒甸咯
//+++立加阑 拌加 蜡瘤窍搁辑 单捞磐 价荐脚 窍扁 困秦辑 胶饭靛 按眉 积己++++
//胶饭靛 按眉狼 积己磊肺 家南 按眉客 秦浆 甘阑 逞败淋
ChatServerThread childThread=new ChatServerThread(child, hm);
Thread t = new Thread(childThread);
t.start(); //胶饭靛 矫累
}catch(Exception e){
e.printStackTrace(); //俊矾 皋矫瘤甫 免仿窍绊
System.exit(0); //橇肺弊伐阑 辆丰茄促.
}
}//while 场
}//积己磊 场
public static void main(String[] args) {
new ChatServerEx( );
}//main场
}//ChatServerEx
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -