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

  • SEARCH
  • Home
  • 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 6206463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:27:16+00:00 2026-05-24T05:27:16+00:00

Issue I have confirmed via a packet sniffer that all data coming from the

  • 0

Issue

I have confirmed via a packet sniffer that all data coming from the client is being totally sent, and that the data being received by the server is complete as well, however there is a slight problem.

Here is a basic representation of relevant parts of the client thread within the server.

this.data_in = new DataInputStream(sock.getInputStream());
this.in = new InputStreamReader(this.data_in);

The server will read in authentication data using the BufferedReader, and once authentication is complete it will read data from the socket, like so. The variable ‘fos’ is a FileOutputStream that the DataInputStream data is being written to.

int read = 0;
byte[] buffer = new byte[8192];
while((read = data_in.read(buffer)) != -1) {
    fos.write(buffer, 0, read);
    bytes_received += read;
}

This all seems correct in concept, however, in practice the first 1450 bytes of the file read in are missing. I have tried using a new DataInputStream(sock.getInputStream()) in case the position in the stream was weird but still no luck. Thanks for any help!

Update 1

So I could use BufferedReader functionality I made a method to read in string lines as I was using them before. See below code.

int input;
boolean run = true;
while((input = in.read()) != -1 && run) {
    run = true;
    char[] chars = Character.toChars(input);
    for(char c : chars) {
        if(c == '\n') {
            run = false;
            break;
        } else if(c != '\r') {
            sb.append(c);
        }
    }
}

As great of a solution it seemed, there is still 1450 bytes of information missing. Maybe I’m going in the wrong direction here?

  • 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-05-24T05:27:18+00:00Added an answer on May 24, 2026 at 5:27 am

    To me it looks like the BufferedReader is the problem – according to http://ulibgcj.sourceforge.net/javadoc/java/io/BufferedReader.html is has default buffer size of 8192… whatever this default buffer size is in your case, the BufferedReader will advance the data_in in steps of that default buffer size… so even if you don’t consume them data_in is usually on a position beyond the last bytes you consumed during authentication.

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

Sidebar

Related Questions

Here's the issue: I have 2 data contexts that I would like to do
I have issue that is reproduced on g++. VC++ doesn't meet any problems. So
Here's the issue: I have a hook in IE that reacts on WebBrowser.OnNavigateComplete2 event
Here's the issue: I have a list of App names that I want to
This would be my issue I have a drop down that's not displaying fully.
I have a Java client that connects to a C++ server using TCP Sockets
I have an issue with broadcasting Datagram packets from one Android phone to the
OK, i have confirmed i only this issue when i attempt to query on
I have a Highchart scatter chart that plots data calculated using a PHP script.
I have a GUI application that doesn't have a memory leak. I have confirmed

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.