I have a web server (started from a service):
public class WebServer extends Thread {
private boolean isRunning = false;
protected Context context = null;
private int serverPort;
private BasicHttpProcessor httpproc = null;
private BasicHttpContext httpContext = null;
private HttpService httpService = null;
protected HttpRequestHandlerRegistry registry = null;
private NotificationManager notifyManager = null;
public WebServer(Context context, NotificationManager notifyManager, String serverName, int serverPort) {
super(serverName);
this.setContext(context);
this.setNotifyManager(notifyManager);
this.serverPort = serverPort;
// SharedPreferences pref =
// PreferenceManager.getDefaultSharedPreferences(context);
this.httpproc = new BasicHttpProcessor();
this.httpContext = new BasicHttpContext();
this.httpproc.addInterceptor(new ResponseDate());
this.httpproc.addInterceptor(new ResponseServer());
this.httpproc.addInterceptor(new ResponseContent());
this.httpproc.addInterceptor(new ResponseConnControl());
this.httpService =
new HttpService(this.httpproc, new DefaultConnectionReuseStrategy(),
new DefaultHttpResponseFactory());
this.registry = new HttpRequestHandlerRegistry();
setHandlerRegistry();
this.httpService.setHandlerResolver(this.registry);
}
protected void setHandlerRegistry() {}
@Override
public void run() {
super.run();
try {
ServerSocket serverSocket = new ServerSocket(this.serverPort);
serverSocket.setReuseAddress(true);
while (this.isRunning) {
try {
final Socket socket = serverSocket.accept();
DefaultHttpServerConnection serverConnection =
new DefaultHttpServerConnection();
serverConnection.bind(socket, new BasicHttpParams());
this.httpService.handleRequest(serverConnection, this.httpContext);
serverConnection.shutdown();
}
catch (IOException e) {
e.printStackTrace();
}
catch (HttpException e) {
e.printStackTrace();
}
}
serverSocket.close();
}
catch (IOException e) {
e.printStackTrace();
}
}
And sometimes, there is a error message (trace) logged for this code line when I receive some data from my client; this error is random:
this.httpService.handleRequest(serverConnection, this.httpContext);
The error message is: W/System.err(1052) at ....
Thank you guys !