There is a problem running websocket under IE, but Firefox is running normally.

Source: Internet
Author: User
Keywords Php html5
Tags sha1
I used PHP to write a socket server, and then after the Firefox run client handshake successfully,
1. Send a message to the server using the Send () function
2. Service-side Socket__read extract information
3. Re-use the Socket__write return information to trigger the client's OnMessage event.

And under IE and chrome, it doesn't trigger the OnMessage event,
1. First send () sends the message to the server
2.socket__select get socket A, Socket__read get information
3. Return the same information to socket a with socket__write, then listen for socket A, and it will end in Firefox.
However, under IE, socket__select will get socket a again, and then repeat the acquisition and return information to the last listener socket A. Of course, Socket__select will also get socket A, after the first two read and write, this time the Socket__read obtained information will be null value.

By the way, in IE, the first time the server executes the Socket__write return value is int (10), which is normal, and the second write will return int (32), because the PHP file is run under CMD, the information obtained by Socket__read is displayed as Garbled (handshake protocol is shown normal), so I do not know the second time Socket__write return information is what.
Why is that? Obviously shook hands can succeed again, OnOpen event has been triggered, why to OnMessage when there is a problem!

If the above information cannot find the problem, here is my code:
Html:


  
   
  
   
  
   
  
   test

Send

Php:


  

Reply content:

I used PHP to write a socket server, and then after the Firefox run client handshake successfully,
1. Send a message to the server using the Send () function
2. Service-side Socket__read extract information
3. Re-use the Socket__write return information to trigger the client's OnMessage event.

And under IE and chrome, it doesn't trigger the OnMessage event,
1. First send () sends the message to the server
2.socket__select get socket A, Socket__read get information
3. Return the same information to socket a with socket__write, then listen for socket A, and it will end in Firefox.
However, under IE, socket__select will get socket a again, and then repeat the acquisition and return information to the last listener socket A. Of course, Socket__select will also get socket A, after the first two read and write, this time the Socket__read obtained information will be null value.

By the way, in IE, the first time the server executes the Socket__write return value is int (10), which is normal, and the second write will return int (32), because the PHP file is run under CMD, the information obtained by Socket__read is displayed as Garbled (handshake protocol is shown normal), so I do not know the second time Socket__write return information is what.
Why is that? Obviously shook hands can succeed again, OnOpen event has been triggered, why to OnMessage when there is a problem!

If the above information cannot find the problem, here is my code:
Html:


  
   
  
   
  
   
  
   test

Send

Php:


  

Reference: https://segmentfault.com/q/1010000004859 ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.