关于.NET和FLEX的SOCKET连接
问题是我这边的.NET返回安全策略的文件FLEX那里接受不到,然后就会报安全沙箱的错误。应该是我写错了,但是不知道错那里。我也监听过843端口,但是不行,希望有人能改下我...
问题是我这边的.NET返回安全策略的文件FLEX那里接受不到,然后就会报安全沙箱的错误。应该是我写错了,但是不知道错那里。我也监听过843端口,但是不行,希望有人能改下我的代码,或者给我个DEMO也行。谢谢了。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Sockets;
using System.IO;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
TcpListener listener;
try
{
listener = new TcpListener(13000);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
return;
}
listener.Start();
Console.WriteLine("服务器启动,等待客户端连接.");
bool loop = true;
while (loop)
{
Socket sc = listener.AcceptSocket();
NetworkStream ns = new NetworkStream(sc);
StreamReader reader = new StreamReader(ns);
string result = string.Empty;
try
{
result = reader.ReadLine();
if (result.Contains("<policy-file-request/>\0"))
{
string xml = "<cross-domain-policy><site-control permitted-cross-domain-policies=\"all\"/>";
xml = xml + "<allow-access-from domain=\"*\" to-ports=\"13000\"/>";
xml = xml + "</cross-domain-policy>\0";
byte[] b = new byte[0] { };
b = System.Text.Encoding.UTF8.GetBytes(xml.ToCharArray());
sc.Send(b);
sc.Close();
Console.WriteLine("连接失败");
}
else
{
Console.WriteLine("连接成功");
}
//s.Close();
}
catch (Exception ex)
{
Console.WriteLine("asdad");
Console.WriteLine(ex.Message);
}
}
}
}
} 展开
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Sockets;
using System.IO;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
TcpListener listener;
try
{
listener = new TcpListener(13000);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
return;
}
listener.Start();
Console.WriteLine("服务器启动,等待客户端连接.");
bool loop = true;
while (loop)
{
Socket sc = listener.AcceptSocket();
NetworkStream ns = new NetworkStream(sc);
StreamReader reader = new StreamReader(ns);
string result = string.Empty;
try
{
result = reader.ReadLine();
if (result.Contains("<policy-file-request/>\0"))
{
string xml = "<cross-domain-policy><site-control permitted-cross-domain-policies=\"all\"/>";
xml = xml + "<allow-access-from domain=\"*\" to-ports=\"13000\"/>";
xml = xml + "</cross-domain-policy>\0";
byte[] b = new byte[0] { };
b = System.Text.Encoding.UTF8.GetBytes(xml.ToCharArray());
sc.Send(b);
sc.Close();
Console.WriteLine("连接失败");
}
else
{
Console.WriteLine("连接成功");
}
//s.Close();
}
catch (Exception ex)
{
Console.WriteLine("asdad");
Console.WriteLine(ex.Message);
}
}
}
}
} 展开
1个回答
上海德康电子
2023-06-12 广告
2023-06-12 广告
T-BOX接插件是一种常见的汽车连接器,用于将汽车的电源和信号线连接到车辆的电子设备上。根据我的知识,T-BOX接插件有以下几种型号:1. T-BOX 0437:这是一种标准的T-BOX接插件,适用于欧洲和北美地区。2. T-BOX 152...
点击进入详情页
本回答由上海德康电子提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询