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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:31:39+00:00 2026-05-31T17:31:39+00:00

somebody know what is encoding type of message that client sends to websocket server?

  • 0

somebody know what is encoding type of message that client sends to websocket server?

I’m studying this site

http://blogs.claritycon.com/blog/2012/01/18/websockets-with-rfc-6455/

and from what this site teaches me, below are decoding code to get message from client in server side!!!

public string HybiDecode(byte[] data)
{
    byte firstByte = data[0];
    byte secondByte = data[1];
    int opcode = firstByte & 0x0F;
    bool isMasked = ((firstByte & 128) == 128);
    int payloadLength = secondByte & 0x7F;

    if (!isMasked) { return null; } // not masked
    if (opcode != 1) { return null; } // not text

    List<int> mask = new List<int>();
    for (int i = 2; i < 6; i++)
    {
        mask.Add(data[i]);
    }
    int payloadOffset = 6;
    int dataLength = payloadLength + payloadOffset;

    List<int> unmaskedPayload = new List<int>();
    for (int i = payloadOffset; i < dataLength; i++)
    {
        int j = i - payloadOffset;
        unmaskedPayload.Add(data[i] ^ mask[j % 4]);
    }

    return ToAscii(unmaskedPayload.Select(e => (byte)e).ToArray());
}

public string ToAscii(byte[] data)
{
    System.Text.ASCIIEncoding decoder = new System.Text.ASCIIEncoding();
    return decoder.GetString(data, 0, data.Length);
}

but now I’m studying in C language so I have to convert ToAscii() to C language!
but… from what? from unicode to ASCII or from utf-8 to ASCII???
could you let me know if you know about 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-05-31T17:31:40+00:00Added an answer on May 31, 2026 at 5:31 pm

    Messages are transmitted as utf-8. See section 5.6 of the spec for details.

    Its up to you what encoding you use within your server. UTF-8 is easy to handle in C (it is still terminated by single nul character so all string functions work) so you might find it easiest to use UTF-8 in your code and not convert to ascii/unicode.

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

Sidebar

Related Questions

Does somebody know why the output of this code is only : Message Sended
i would to know if somebody knows a methodology or whatever that be capable
I don't know if I'm thinking of this the right way, and perhaps somebody
Does somebody know a script that is able to convert a string to a
Does somebody know a quick and easy explode() like function that can ignore splitter
Does somebody know how to achieve this with XSL-FO transformation? The question details should
Somebody know how use OpenX (php app) with Django? I need to use OpenX
Does somebody know how to recover a never-starting eclipse when the error org.eclipse.swt.SWTError: Item
Does somebody know a Java library which serializes a Java object hierarchy into Java
I'm using a subversion repository and I want to know whenever somebody asks my

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.