Fully complete solution for WebSocket (compatible with IE9)

Source: Internet
Author: User
Tags server port

1, the client's page with the following address, run sample

Https://github.com/gimite/web-socket-js

2, the server side with the following can be
Https://github.com/statianzo/Fleck

3, follow the above steps can not support IE9
To perform the following service, copy the following code, generate a console program, and then execute it on the server side.

After the Adobe Flash player upgrade to 9.0.124, due to security policy changes, so that in the socket or Xmlsocket applications, the original HTTP mode to load security policy can not continue to use, similar to such applications must use the Xmlsocket ://way to provide security policy. The Flashplayer security policy detection process is as follows:

1, first detect whether the target server port 843 provides a security policy

2, if 1 does not detect a policy, detects if ActionScript is using the

Security.loadpolicyfile (xmlsocket://)

means to provide a security policy, and if not detected, use the 3rd step detection

3, detects if the target server destination port provides a security policy

C # code below, compilation environment VS2008 +. NET Framework 3.5

usingSystem; usingSystem.Text; usingSystem.Net; usingSystem.Net.Sockets; usingSystem.Threading; usingSystem.Collections; namespaceServerSocket {classProgram {PrivateThread beginthread, Receivethread; PrivateSocket ServerSocket, Clientsocket; Static voidMain (string[] args) { Program Program=NewProgram (); IPEndPoint Remotepoint=NewIPEndPoint (Ipaddress.any,843); Program.serversocket=Newsockets (AddressFamily.InterNetwork, SocketType.Stream, protocoltype.tcp);              Program.serverSocket.Bind (Remotepoint); Program.serverSocket.Listen (Ten); Console.WriteLine ("Listening ..."); Program. Beginthread=NewThread (NewThreadStart (program.              Beginlisten)); Program.          Beginthread.start (); }             Private voidBeginlisten () { while(true) {Clientsocket=serversocket.accept (); Receivethread=NewThread (NewThreadStart (receive)); Receivethread.              Start (); }          }             Private voidreceive () {IPEndPoint clientep=(IPEndPoint) clientsocket.remoteendpoint; intbytes =0;  while(true) {byte[] buffer=Newbyte[ -]; Bytes=clientsocket.receive (buffer); if(Bytes >0)                  {                      stringClientcommand = Encoding.UTF8.GetString (buffer,0, bytes); String Policy="<cross-domain-policy><allow-access-from domain=\ "*\" to-ports=\ "2999\"/></cross-domain-policy >\0"; Buffer=System.Text.Encoding.UTF8.GetBytes (policy.                         ToCharArray ()); Clientsocket.send (buffer, buffer. Length,0); }                  Else                  {                       Break;              }} clientsocket.close (); Receivethread.          Abort (); }      }  } 

Fully complete solution for WebSocket (compatible with IE9)

Related Article

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.