|
public class NetworkActionServer extends Thread{
private static final int serverport = 8899;
private Socket serversocket;
DBAction db=new DBAction();
NetworkActionServer(Socket i){
this.serversocket=i;
}
//获得C发来的消息,返回验证消息
public void run() {
try {
//get client mes
ObjectInputStream InputStream = new ObjectInputStream(serversocket.getInputStream());
User usr=(User) InputStream.readObject();
//do client mes
db.insertInto(usr);
//返回验证消息
ObjectOutputStream OutputStream = new ObjectOutputStream(serversocket.getOutputStream());
User[] dbusr=db.selectall();
for(int i=0;i<dbusr.length;i++){
System.out.println(dbusr[i].getName());
OutputStream.writeObject("a");////////////
/////////////////////////在这里写不不了对象,有 socket write error
//Thread.sleep(3000);
}
OutputStream.flush();
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String arg[]){
try{
ServerSocket servercon = new ServerSocket(serverport);
while(true){
Socket s=servercon.accept();
Thread t=new NetworkActionServer(s);
t.start();
}
}catch(Exception e){
e.printStackTrace();
}
}
}
就是
socket write error.....大家帮忙,谢谢
|
|