大家好,请提前谢谢,请原谅我的英语水平差,但我想要一些帮助: 我的问题是我正在尝试创建一个通过Intenet发送字节的应用程序 我试图连接它说: 连接无法完成机器actvely拒绝IP:PORT
保持明白:
public static void start()
{
SocketPermission permission = new SocketPermission(NetworkAccess.Accept, TransportType.Tcp,"", SocketPermission.AllPorts);
sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, Settings.Protcole);
permission.Demand();
IPEndPoint end = new IPEndPoint(IPAddress.Any, Settings.Port);
sock.Bind(end);
sock.Listen(10);
accepted = sock.Accept();
Connected = true;
}
public static void Connect(string IP)
{
try
{
SocketPermission permission = new SocketPermission(NetworkAccess.Accept, TransportType.Tcp, Server.GetIP(), SocketPermission.AllPorts);
sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, Settings.Protcole);
permission.Demand();
IPEndPoint end = new IPEndPoint(IPAddress.Parse(IP), Settings.Port);
sock.Connect(end);
Connected = true;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "O.o", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}