public void Send()
{
IPAddress[] ip = Dns.GetHostAddresses(Dns.GetHostName());
string addres = ip[0].ToString();
TcpClient client = new TcpClient(AddressFamily.InterNetwork);
client.Connect(ip, 1450);
NetworkStream stream = client.GetStream();
byte[] content = Encoding.ASCII.GetBytes(DateTime.Now.ToString());
while (true)
{
stream.Write(content, 0, content.Length);
Console.WriteLine("开始发送");
stream.Close();
Thread.Sleep(5000);
} }上面是我写的一个简单的发送,为什么就是发送不了呢??异常:由于目标机器积极拒绝,无法连接。 192.168.1.101:1450
{
IPAddress[] ip = Dns.GetHostAddresses(Dns.GetHostName());
string addres = ip[0].ToString();
TcpClient client = new TcpClient(AddressFamily.InterNetwork);
client.Connect(ip, 1450);
NetworkStream stream = client.GetStream();
byte[] content = Encoding.ASCII.GetBytes(DateTime.Now.ToString());
while (true)
{
stream.Write(content, 0, content.Length);
Console.WriteLine("开始发送");
stream.Close();
Thread.Sleep(5000);
} }上面是我写的一个简单的发送,为什么就是发送不了呢??异常:由于目标机器积极拒绝,无法连接。 192.168.1.101:1450
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货