All,
I am developing a mini webserver on a JavaME 8.1 board.
I am using the PrintStream class
final OutputStream socketOutputStream = client.openOutputStream();
out = new PrintStream(socketOutputStream);
out.println("HTTP/1.0 200 OK");
out.println("");// this blank line signals the end of the headers
out.print("<!DOCTYPE html>");
...
Unfortunately it is very slow. It takes about 20 seconds for 500 Bytes. In our case it is common that our HTML5 page is about 5k!
The Troubleshooting page informs that the network layer does not provide buffering for sockets. Hence I changed the output stream to the following as suggested
final OutputStream socketOutputStream = client.openOutputStream();
// Socket performance workaround:
// make additional buffering around socket's output stream
OutputStream bufferedOutputStream = new ByteArrayOutputStream() {
public void flush() {
try {
writeTo(socketOutputStream);
reset();
socketOutputStream.flush();
} catch (IOException ioe) {
}
}
}
out = new PrintStream(bufferedOutputStream);
The issue is still there and there is no improvement. Any idea?
Thanks,
-- Daniel