Skip to Main Content

Embedded Technologies

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Socket OutputStream very very slow

2987002Aug 10 2015 — edited Nov 11 2015

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

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 9 2015
Added on Aug 10 2015
2 comments
2,605 views