日期:2014-05-20 浏览次数:20761 次
package com.lzz.test;
import java.io.IOException;
import java.net.*;
import java.io.*;
public class ChatServer {
public static void main(String[] args) {
boolean falg = true;
ServerSocket ss = null;
Socket s = null;
try {
ss = new ServerSocket(8888);
} catch (IOException e) {
e.printStackTrace();
}
while (falg) {
boolean bfalg = false;
s = ss.accept();
System.out.print("服务器启动了");
try {
bfalg = true;
DataInputStream dis = new DataInputStream(s.getInputStream());
while (bfalg) {
String str = dis.readUTF();
System.out.println(str);
}
dis.close();
s.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
import java.net.*;
import java.io.*;
public class Test {
public static void main(String[] args){
boolean falg = true;
ServerSocket ss = null;
Socket s = null;
try {
ss = new ServerSocket(8888);