在服务器的循环语句中,这段代码只能进行服务器的一次响应
try{
while(true){ **serversocket=new ServerSocket(6000);** socket=serversocket.accept(); Thread workthread=new Thread(new ClientRun(socket)); workthread.start(); } } catch(IOException e){ } finally{ }
当将serversocket=new ServerSocket(6000);取出循环后,服务器就能进行多次响应,这是为啥呢。。。
try{
**serversocket=new ServerSocket(6000);** while(true){ serversocket=new ServerSocket(6000); socket=serversocket.accept(); Thread workthread=new Thread(new ClientRun(socket)); workthread.start(); } } catch(IOException e){ } finally{ }
一只甜甜圈
相关分类