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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:11:55+00:00 2026-06-13T23:11:55+00:00

I know that there are things out there roughly on this.. But my brains

  • 0

I know that there are things out there roughly on this.. But my brains hurting and I can’t find anything to make this work…

I am trying to send an 16 bit unsigned integer over a unix socket.. To do so I need to convert a uint16_t into two chars, then I need to read them in on the other end of the connection and convert it back into either an unsigned int or an uint16_t, at that point it doesn’t matter if it uses 2bytes or 4bytes (I’m running 64bit, that’s why I can’t use unsigned int 🙂

I’m doing this in C btw

Thanks

  • 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-13T23:11:55+00:00Added an answer on June 13, 2026 at 11:11 pm

    Why not just break it up into bytes with mask and shift?

     uint16_t value = 12345;
     char lo = value & 0xFF;
     char hi = value >> 8;
    

    (edit)

    On the other end, you assemble with the reverse:

     uint16_t value = lo | uint16_t(hi) << 8;
    

    Off the top of my head, not sure if that cast is required.

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

Sidebar

Related Questions

I know that there are lots of examples out there on this, but they
There are many things that all programmers should know, but I am particularly interested
I know that there are lot's of questons on this, but all seem to
I know that there can be multiple values for an email, but I'm not
I know that there are people out there creating classes for this (ie http://coreyoneil.com/portfolio/index.php?project=5
Is there a set of things that every JavaScript programmer should know to be
Is there such a thing? I know that I can hook my function on
I know that there are some threads have a similar issue with this thread.
I know that there are others posts with solutions on the site but i
I know that there is no official Pandora API for iPhone devs, but I'm

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.