```java
import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Properties;
public class server {
public static void main(String arg[]) {
wangluo.w = new wangluo[5];
byte len = (byte)wangluo.w.length;
Socket s = null;
ServerSocket ss = null;
try {
ss = new ServerSocket(8888);
} catch (IOException e) {
e.printStackTrace();
}
System.out.println("server is readying");
byte i;
while (true){
for (i=0;;i++) {
if (i == len) i = 0;
if (wangluo.w[i]!=null) continue;
if (wangluo.w[i]==null) break;
}
System.out.println(wangluo.sum+" 号位等待中......");
try {
s = ss.accept();
} catch (IOException e) {
e.printStackTrace();
}
wangluo.w[i] = new wangluo(i,s);
}
}
}
class wangluo extends Thread{
public static byte sum;
public static wangluo[] w;
private boolean alive=false;
private String name ="";
private byte i;
private Socket s = null;
private InputStream input = null;
private OutputStream output = null;
public wangluo(byte i,Socket s) {
this.i = i;
this.s = s;
try {
input = s.getInputStream();
output = s.getOutputStream();
} catch (IOException e) {
e.printStackTrace();
}
start();
}
@Override
public void run() {
alive = check();
sum++;
String data;
while(alive){
data = getdata();
for (int j=0;j<w.length&&alive;j++){
if (j!=i&&w[j]!=null&&w[j].alive) w[j].write(data.getBytes());
}
}
sum--;
}
private boolean check(){
boolean bool = true;
FileInputStream f = null;
name = getdata();
String pass = getdata();
try {
f = new FileInputStream("server.properties");
Properties p = new Properties();
p.load(f);
if(!pass.equals(p.getProperty(name))) bool = false;
else write("ok".getBytes());
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}finally {
if (f!=null) {
try {
f.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return bool;
}
private void close(){
alive = false;
try {
s.close();
} catch (IOException e) {
e.printStackTrace();
}
try {
input.close();
} catch (IOException e) {
e.printStackTrace();
}
try {
output.close();
} catch (IOException e) {
e.printStackTrace();
}finally {
w[i] = null;
}
}
public void write(byte[] i){
try {
output.write(i);
} catch (IOException e) {
close();
}
}
public void write(byte i){
try {
output.write(i);
} catch (IOException e) {
close();
}
}
private String getdata(){
String data = "";
byte dat = 0;
try {
while((dat = (byte) input.read())!=0){
if(dat==-1) {
close();
break;
}
data = data+(char)dat;
}
write("ds".getBytes());
} catch (IOException e) {
close();
}
return data;
}
}