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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:32:01+00:00 2026-06-03T07:32:01+00:00

Suppose I get from the network a sequence of bytes in the following order:

  • 0

Suppose I get from the network a sequence of bytes in the following order:
X X X X = X X X X = X X X X = … and so on
you can notice immediately the pattern (a message is a sequence of 5 bytes: “X X X X =
X can be any number except ‘=’ of course)

Now, the transmission occur periodically.
In some point my application is starting and getting the bytes sequence

What is the best algorithm for taking those bytes and framing them to 5 bytes messages?
There are two problems:
1. How do you find the first message? I guess I need to drop some bytes till I get ‘=’ right?
2. How the application suppose to handle a pause of transimmision and a new start.

  • 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-03T07:32:02+00:00Added an answer on June 3, 2026 at 7:32 am

    The simplest way is to use a blocking read (which is the most common because its the simplest) to read 5 bytes at a time.

    Normally, you wouldn’t assume you have junk data at the start, and just read everything. If you have a header, I would read that too.

    DataInputStream dis = new DataInputStream(socket stream);
    byte[] bytes = new byte[5];
    
    int sep;
    do {
      dis.readFully(bytes);
      process(bytes);
    } while((sep = dis.read()) == '=');
    if (sep > 0)
       System.err.println("Unexpected character "+ (char) sep));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one simple app that suppose to get information from user and send
Suppose you want to get a record from database which returns a large amount
How to get user roles from Membership provider? Suppose I have a username and
I am supposed to get some XML data from the server say, <?xml><a></a><?xml><a></a><?xml><a></a><?xml><a></a> Suppose
I am trying to get the available bandwidth from my PC. Suppose I'm streaming
Suppose I get, on a page, this simple html/script : <a id=hey href=#>try</a> var
According to Apple's description, the aurioTouch sample app is suppose to get the audio
How to get file size of pdf,gif,doc etc using xcode. suppose to i get
Suppose I have: class Foo { public String Bar { get; set; } }
suppose I have {data: {243232: {id: testid,name: test } }} so how to get

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.