Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8642849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:53:06+00:00 2026-06-12T11:53:06+00:00

My program uses a SSL ServerSocket to wait for incoming connections and receive data.

  • 0

My program uses a SSL ServerSocket to wait for incoming connections and receive data.
The client connects to the server and writes a sequence of 10-byte-chunks to the Socket‘s OutputStream. After each 10-byte-chunk the OutputStream is flush()ed because the chunk should arrive at the server as soon as possible (Note: WIFI is used here).

These chunks are then read by the server. Running the server on Ubuntu Linux using OpenJDK 7 works fine.

But running the server on Windows using Suns Java 7 causes the following problem:
I measured the time on the server between the received chunks. I noticed that although the client uses flush() after a chunk was written, the data is sometimes received/read by the server too late.

For example:
It takes 265ms to receive the first chunk. The next 15 chunks have a delay of 0ms to 16ms.
After that the next chunk arrives after 172ms. But the following 10 chunks again need only 0ms to 16ms.

So it seems that first some bytes are received and buffered by the InputStream. Then at some point (e.g. more than 150ms later) the InputStream‘s read-method returns some data. After that the read-method returns data immediately (0ms to 16ms) for some bytes. And then it needs some time again.
I know that an InputStream uses buffers and the read-method blocks until a new byte is available. But it seems that the read-method does not return data as fast as it could.

The client was always an Android-App. But since the problem does not occurr with the server running on Linux (always 20ms avg. between chunks) the problem must be the server or JRE.

Any ideas on how to solve the problem? I really need a “fluid” transfer of chunks sent by the client, because interactions on the Android-App should be shown on the server as an animation in near realtime. But with a delay of 265ms these animations stuck.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T11:53:08+00:00Added an answer on June 12, 2026 at 11:53 am

    InputStream buffers data

    No it doesn’t. There isn’t any InputStream buffering, unless you use a BufferedInputStream. Your sends are being coalesced by the TCP Nagle algorithm, in the kernel. Call Socket.setTcpNoDelay(true) at the sender.

    You should be aware that sending 10-byte chunks over SSL is extremely inefficient. SSL itself has a record overhead of about 44 bytes, and TCP another twenty, so you have a data explosion of nearly 4x. Use plaintext if you possibly can for this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a client-server program that uses sockets to transfer information in a stateful
Part of my program uses an event handler for the receive data of my
My program uses a NetworkOutput object which can be used to write data to
Question: I have written a console program that uses the SQL server 2005 web
My program uses shared memory as a data storage. This data must be available
My program uses UDP to send data between two programs, it works great however
I have written a simple SSL Client/Server set of programs from a few tutorials
My Program uses EF to access data from a SQL CE database. When debug
There is nothing in the way the program uses this data which will cause
My program uses wx.ProgressDialog to give feedback on a process that is in multiple

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.