import java.io.IOException;
import java.net.UnknownHostException;
public class ChatRoomClient {
public static void main(String[] args) {
MySocket mySocket = null;
try {
String line = null;
mySocket = new MySocket();
ReadThread rt = new ReadThread(mySocket);
Thread t = new Thread(rt);
t.start();
while(true) {
System.out.print("请曰:");
line = mySocket.readKey();
mySocket.send(line);
}
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
mySocket.close();
}
}
}
class ReadThread implements Runnable {
private MySocket mySocket = null;
public ReadThread(MySocket mySocket) {
super();
this.mySocket = mySocket;
}
@Override
public void run() {
String line;
try {
while(true) {
line = mySocket.receive();
System.out.println(line);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
最近下载更多
最近浏览更多
dapeng0011 LV15
2024年7月18日
微信网友_7004855557083136 LV1
2024年5月22日
Ji123455 LV8
2023年9月21日
cksndh LV4
2023年8月16日
yybb7435100 LV2
2023年8月7日
buhuia LV4
2023年6月7日
林间听风 LV10
2023年4月7日
linmou LV8
2023年3月19日
gzryue LV6
2023年3月8日
heqian LV17
2023年1月10日

