breezehou
发贴: 35
积分: 0
|
于 2004-05-19 08:57
while (true) { Socket connectionsocket = listensocket.accept(); }
HttpRequest request = new HttpRequest(connectionsocket); 我想你的错误可能是,connectionsocket这个变量未定义,Socket connectionsocket = listensocket.accept();你在while语句里定义的,所以它的作用范围就在while语句里,可以这样写:
while(true) { Socket connectionsocket = listensocket.accept(); HttpRequest request = new HttpRequest(connectionsocket);
//creat a new thread to process the request Thread thread1 = new Thread (request); thread1.start(); }
|