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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:35:06+00:00 2026-06-01T18:35:06+00:00

I have been at this for a bit, and I am new to programing

  • 0

I have been at this for a bit, and I am new to programing with JS. I am making a game using JS, HTML5, node and socket.io. I am working on the protocol right now and I am sending the server strings that are hex.

An example of a string would be: 00010203040506070809

I am having a hard time converting it to: 0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09

What I plan on doing is taking these custom packets and having a switch on my server based on the packets. So for example:

BYTE HEADER | + Packet
0x00        | 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09

Then I call: parsepacket(header, data, len);

function parsepacket(header, data, len){
switch(header)
{
case '0x00':    // not hexed
console.log('The client wants to connect');
// Do some stuff to connect
break;

case '0x01':
console.log('0x01');
break;

case '0x02':
console.log('0x02!');
break;
}
};

Does anyone know how to do this?

  • 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-01T18:35:06+00:00Added an answer on June 1, 2026 at 6:35 pm

    I’m not sure this is what you’re after, but you can convert the string to an array of hex values like this:

    var str = "00010203040506070809",
        a = [];
    
    for (var i = 0; i < str.length; i += 2) {
        a.push("0x" + str.substr(i, 2));
    }
    
    console.log(a); // prints the array
    console.log(a.join(" ")); // turn the array into a string of hex values
    ​console.log(parseInt(a[1], 16));​ // parse a particular hex number to a decimal value
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a bit of a vague notion which I have been running over
This may be a bit of a nooby question, I have been trying to
I have been using this code with great success to pull out the first
I have been using this copy method for quite a while, in lots of
I have been using this as a reference, but not able to accomplish exactly
Okay, this is a bit messy: I'm using Netbeans, and I have a main
I have been fighting with this for a bit now. I’m trying to convert
Hell there, I have been stuck on this for a bit now. I know
This is been making my programming really frustrating lately. I´m in Argentina right now
I have been working on a game for iphone and have run into a

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.