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

The Archive Base Latest Questions

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

I read byte[] from socket as Param_Code which includes ID. byte[] cbuf = new

  • 0

I read byte[] from socket as Param_Code which includes ID.

byte[] cbuf = new byte[4];
socketReader.read(cbuf, 0, 4);
int Param_Code = byteArrayToIntBI(cbuf, 0);

public static int byteArrayToIntBI(byte[] b, int offset) {
        int value = 0;
        for (int i = 3; i > -1; i--) {
            int shift = (i) * 8;
            value += (b[i + offset] & 0x000000FF) << shift;
        }
    return value;
   }

• Option 1: Sometimes the Param_code corresponds only to the ID

• Option 2: Sometimes the Param_code corresponds to 0x40000000 + the ID

• Option 3: Sometimes the Param_code corresponds to 0x80000000 + the ID

My question is, How can i get ID from Param_code considering above options.

  • 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-27T03:16:10+00:00Added an answer on May 27, 2026 at 3:16 am

    How about using ByteBuffer?

    byte[] cbuf = new byte[4];
    socketReader.read(cbuf, 0, 4);
    ByteBuffer buffer = ByteBuffer.wrap(cbuf);
    int Param_Code = buffer.getInt();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I read byte[] from socket as Param_Code . there is a condition for Param_Code
I'm using System.IO.Stream.Read(byte[] buffer, int offset, int count) . Is there an alternative to
I'm trying to use qFromBigEndian to read a 32-bit int from a byte stream
I am using the Naga library to read data from a socket, which produces
I need to read data from socket byte by byte. I try to do
I read in a Byte Array generated from a function called from an external
I have a byte array in memory, read from a file. I would like
I am trying to read a Network Stream from a socket. I know that
I have a stream of bytes that is being read in from a socket
I have created a raw socket which takes all IPv4 packets from data link

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.