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 8476299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:08:27+00:00 2026-06-10T18:08:27+00:00

I am doing some benchmarks on a HTTP server. To avoid potential conflict with

  • 0

I am doing some benchmarks on a HTTP server. To avoid potential conflict with HTTP libraries, I open the connection directly using a Socket, with no HTTP persistent connections.

The Java code opens and connects an InputStream on a socket connected to a loaded HTTP server. It is running on Linux.

I see that that either of these could happen:

  • The socket connect (new Socket()) could take long. This makes sense if the server has a backlog in accepting new connections.
  • The socket connect is fast but the delay, up to 1500 milliseconds, is in the last read when read() returns -1 to signify the stream is at the end of “the file.” This I do not understand.

The code follows the standard, with some timing code added:

final byte[] buffer = new byte[8192];
int size = inputStream.read(buffer);

while (size > 0) {
    // Copy the buffer
    size = inputStream.read(buffer);
}
  • 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-10T18:08:28+00:00Added an answer on June 10, 2026 at 6:08 pm

    The socket connect is fast but the delay, up to 1500 milliseconds, is in the last read when read() returns -1 to signify the stream is at the end of “the file.” This I do not understand.

    Assuming that the scenario is exactly as you’ve explained; i.e. that you simply connected to port 80 and tried to read data:

    • The server is most likely waiting for your client code to send a request.
    • The server times out the read after 1.5 seconds, and then it closes both sides of its socket.
    • That results in the client-side socket seeing an EOF … which is signalled to your code by returning -1 from the read(...) call.

    Basically, your code has to send a well-formed HTTP request to the server if you expect the server to send you a response.

    On the other hand, if your code did send a well-formed HTTP request, then the behaviour could be caused by your code trying to read more data that the server has to send … combined with sending a Request that specified a persistent connection (see HTTP 1.1 spec, section 8.1).

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

Sidebar

Related Questions

After doing some Core animations using: [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:0.5]; [self setAffineTransform:CGAffineTransformIdentity]; [UIView
While doing some refactoring I've found that I'm quite often using a pair or
Been doing some playing call my service which is on a different domain using
I'm doing some PHP memory benchmarks and i would like to obtain the garbage
I'm doing some PHP memory benchmarks and i'm wondering if there is a way
after doing some research i'm still not sure if using mysql with .net desktop
Doing some jquery animation. I have certain divs set up with an attribute of
Doing some homework here (second assignment, still extremely green...). The object is to read
In doing some bioinformatics work, I've been pondering the ramifications of storing object instances
While doing some JavaScript performance tests I came up with the following piece of

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.