99我啊!!大家快来帮忙啊!!!有点难哦!!!!

whs999whs whs999whs 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
问题:Refactoring following simple socket server to mutil thread server.


package test7;

import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class SimpleServer {
public static void main(String [] args){
ServerSocket s = null;
Socket s1;
String sendString = "Hello Net World";
OutputStream slout;
DataOutputStream dos;
try{
s = new ServerSocket(5432);
}catch(Exception ex){ }
while(true){
try {
s1 = s.accept();
slout = s1.getOutputStream();
dos = new DataOutputStream(slout);
dos.writeUTF(sendString);
s1.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
...全文
评论 7
收藏 已收藏
分享
返回顶部
whs999whs
Java SE 62,621 成员 307,251 内容