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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:03:16+00:00 2026-06-13T02:03:16+00:00

I have the following code to read data from a socket. byte[] data =

  • 0

I have the following code to read data from a socket.

byte[] data = new byte[dataLength];

if(dataLength > 2000000)FileManager.writeToLogFile(this.getClass(), "GetIncomingMessages", LogMessageType.DEBUG, "XXXXYYYY => 2 length: " + dataLength);

for(int i = 0 ; i < dataLength ; i++){
    byte[] temp = new byte[1];
    in.read(temp);
    data[i] = temp[0];
}

if(dataLength > 2000000)FileManager.writeToLogFile(this.getClass(), "GetIncomingMessages", LogMessageType.DEBUG, "XXXXYYYY => 3 length: " + dataLength);

This code works fine until I get a pack with the size of around 3MB (3227056 bytes to be exact). When this packet is received, no exception occurs, neither does my program crash, but the code never progresses beyond that point. Basically the last log entry that you see above is not made.

What could be the reason for this ? How could I at least figure out WHAT the error is ? (Error is not caught in any of the try-catch blocks). There are however, other receives that take place beyond this point.

  • 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-13T02:03:17+00:00Added an answer on June 13, 2026 at 2:03 am

    Try:

    if( dataLength ) ...
    
    int readBytes = 0;
    
    while( readBytes < dataLength )
    {
       readBytes += in.read( data, readBytes, dataLength-readBytes);
    }
    
    if( dataLength ) ...
    

    This should make for speed up.

    Note that this is not really a solution to your problem. But I guess the inefficient loop to be a part of it. Hopefully we can edit this answer to come to a solution for you.

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

Sidebar

Related Questions

I have written the following code snippet to read data from the database :
I have the following code that uses Sequence objects to read data from a
I have the following code to read data from my .plist for use in
When I using the following code to read file: lines=file(data.txt).read().split(\n) I have the following
I'm trying to select data from the database and I have the following code
I used the following piece of code to read data from files as part
I have some SerialPort code that constantly needs to read data from a serial
I am trying to read some data from a network socket using the following
I have following code which reads data from text file and prints to browser.
I have the following C# code, which pulls data from a database & populates

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.