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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:15:20+00:00 2026-06-06T10:15:20+00:00

I am trying to create a program that will get data directly from socket

  • 0

I am trying to create a program that will get data directly from socket instead of going through using HttpURLConnection or HttpClient. Using a socket will give me more freedom to manipulate the data to match the requirements. I am hoping that using sockets, I can preserve the chunk headers sent with each chunk. Following is my code to accomplish that. Unfortunately, even though the code runs without any errors, it runs for at least 40 seconds before it stops. Also, I don’t get any InputStream from the server even though I checked that the program was connected to the server.

    Socket socket = new Socket(hostAddr, port);
    InputStream in = socket.getInputStream();
    InputStreamReader isr = new InputStreamReader(in);
    char[] streamBuff = new char[8192];
    StringBuilder receivedData = new StringBuilder();
    int count = 0;
    while((count = isr.read(streamBuff)) > 0)
    {
        receivedData.append(streamBuff, 0, count);
    }
    System.out.println(receivedData);
  • 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-06T10:15:28+00:00Added an answer on June 6, 2026 at 10:15 am

    HTTP/1.1 has persistent connections. You are reading all response chunks in that loop and then block until server times out and closes you TCP connection.

    Edit 0:

    By the way, you are not sending a *request* to the server, that’s why you don’t get anything back. Study the protocol if you want to implement it yourself.

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

Sidebar

Related Questions

I am trying to create a program that will be passed input data from
I'm trying to create a program that will go through a bunch of tumblr
I've been asked to create an app that will get data back from a
I am trying to create a program that will do some simple calculations, but
I have a small program that I'm trying to create to get ip addresses
I'm trying to create a program that will return a certain number decomposed to
I am trying to create a program that will set up a crontab to
I am trying to create a program that will open a text file with
I have been trying to create a Ruby program that will be running online
I am trying to get data from database for Google charts in my program.

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.