示例#1
0
 static void ServePolicyFile(IAsyncResult ar)
 {
     TcpClient cli = (ar.AsyncState as TcpListener).EndAcceptTcpClient(ar);
     (ar.AsyncState as TcpListener).BeginAcceptTcpClient(ServePolicyFile, ar.AsyncState);
     try
     {
         var s = cli.GetStream();
         NReader rdr = new NReader(s);
         NWriter wtr = new NWriter(s);
         if (rdr.ReadNullTerminatedString() == "<policy-file-request/>")
         {
             wtr.WriteNullTerminatedString(@"<cross-domain-policy>
      <allow-access-from domain=""*"" to-ports=""*"" />
     </cross-domain-policy>");
             wtr.Write((byte)'\r');
             wtr.Write((byte)'\n');
         }
         cli.Close();
     }
     catch { }
 }
示例#2
0
        static void ServePolicyFile(IAsyncResult ar)
        {
            TcpClient cli = (ar.AsyncState as TcpListener).EndAcceptTcpClient(ar);

            (ar.AsyncState as TcpListener).BeginAcceptTcpClient(ServePolicyFile, ar.AsyncState);
            try
            {
                var     s   = cli.GetStream();
                NReader rdr = new NReader(s);
                NWriter wtr = new NWriter(s);
                if (rdr.ReadNullTerminatedString() == "<policy-file-request/>")
                {
                    wtr.WriteNullTerminatedString(@"<cross-domain-policy>
     <allow-access-from domain=""*"" to-ports=""*"" />
</cross-domain-policy>");
                    wtr.Write((byte)'\r');
                    wtr.Write((byte)'\n');
                }
                cli.Close();
            }
            catch { }
        }