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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T14:51:17+00:00 2026-06-07T14:51:17+00:00

I’m programming a web socket server in PHP, because I could not find one

  • 0

I’m programming a web socket server in PHP, because I could not find one that supported the RFC 6455 spec. In doing so, I used the phpwebsocket code as a base and made it RFC 6455 compatible. At least I did for the receive message part. When ever I try to send a message back to the server I get different messages. I’m sure this is due to my skills at bit masking being … terrible. So after quite a bit of trial and error I still have this problem, and I have no idea why.

  Time                     OpCode Mask Length Data
1>2012-06-25T18:05:58.014Z 1      true 4      Ping
2>2012-06-25T18:06:02.121Z 1      true 5      hello
3 2012-06-25T18:06:02.121Z A server must not mask any frames that it sends to the server.

or

3 2012-06-25T18:06:02.121Z Unexpected continuation frame.

I’m using PHP 5.4.4 on my computer, using the command line interface. php ws.php is all I need to do in order to start the web socket server. I then use the wsClient.html as my client. Using the latest version of Google Chrome (21.0.1180.4 dev-m) on Windows 8 Preview I’m getting the following message.

You can download the php server and client from my github repo and play long from there. The problem is in the WebSockets::send function.

private function send($client, $payload)
{
    $frame = pack('C2a*', 0b10000001, 0b01111111 & strlen($payload), $payload);
    socket_write($client, $frame, strlen($frame));
}

What am I doing wrong?

  • 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-07T14:51:18+00:00Added an answer on June 7, 2026 at 2:51 pm

    My problem was that I was using little-endian style and not big-endian style when using the binary syntax. I was doing 0b10000001, 0b01111111 when I should be been doing 0b10000001, 0b11111110.

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Seemingly simple, but I cannot find anything relevant on the web. What is the
I need a function that will clean a strings' special characters. I do NOT
I'm trying to create an if statement in PHP that prevents a single post
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string

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.