websocket的全完全解決方案(相容ie9)

來源:互聯網
上載者:User

標籤:else   .text   family   internet   更改   ogr   and   步驟   sockets   

1、用戶端的頁面用下面這個地址,運行sample

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

2、伺服器端用下面這個即可
https://github.com/statianzo/Fleck

3、按照上面的步驟還不能支援ie9
要執行下面這個服務,拷貝下面的代碼,產生一個控制台程式,然後在伺服器端執行著

在Adobe Flash Player升級到9.0.124後,由於安全性原則的更改,使得在socket或xmlsocket的應用裡,原先如用http方式載入安全性原則的手段不能繼續使用了,類似此類應用必須使用xmlsocket://方式來提供安全性原則。flashplayer的安全性原則檢測過程如下:

1,首先檢測目標伺服器的843連接埠是否提供安全性原則

2,如果1沒有檢測到策略,則檢測actionscript是否使用了

Security.loadPolicyFile(xmlsocket://)

手段提供安全性原則,如果還沒檢測到,則使用第3步檢測

3,檢測目標伺服器目標連接埠是否提供安全性原則

C#代碼如下,編譯環境VS2008 + .NET framework 3.5

using System;  using System.Text;  using System.Net;  using System.Net.Sockets;  using System.Threading;  using System.Collections;     namespace serverSocket  {      class Program      {          private Thread Beginthread, receivethread;          private Socket serverSocket, ClientSocket;             static void Main(string[] args)          {              Program program = new Program();                 IPEndPoint remotePoint = new IPEndPoint(IPAddress.Any, 843);                 program.serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);                 program.serverSocket.Bind(remotePoint);              program.serverSocket.Listen(10);                 Console.WriteLine("Listening...");              program.Beginthread = new Thread(new ThreadStart(program.BeginListen));              program.Beginthread.Start();          }             private void BeginListen()          {              while (true)              {                  ClientSocket = serverSocket.Accept();                  receivethread = new Thread(new ThreadStart(receive));                  receivethread.Start();              }          }             private void receive()          {              IPEndPoint clienTep = (IPEndPoint)ClientSocket.RemoteEndPoint;                 int bytes = 0;                 while (true)              {                  Byte[] buffer = new Byte[24];                  bytes = ClientSocket.Receive(buffer);                     if (bytes > 0)                  {                      string clientCommand = 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();          }      }  } 

 

websocket的全完全解決方案(相容ie9)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.