主题:版主和高手看看这是什么问题?
IPAddress attackaddr = IPAddress.Parse("IP地址");
int port = 2000;
try
{
TcpClient tcpc = new TcpClient();
tcpc.Connect(attackaddr, port);
NetworkStream stream = tcpc.GetStream();
if (stream.CanWrite)
{
byte[] code = new byte[3];
string str_code = "hhh";
code = Encoding.ASCII.GetBytes(str_code);
stream.Write(code, 0, code.Length);
}
}
catch (Exception e_client)
{
MessageBox.Show(e_client.Message);
}
c#写的,连接一个机子,总会报错:“由于目标机器积极拒绝,无法连接。”
请教版主和各位高手,到底哪出问题了?
PS:IP地址不会有错,连自己的机子也会出现上面的错误。
int port = 2000;
try
{
TcpClient tcpc = new TcpClient();
tcpc.Connect(attackaddr, port);
NetworkStream stream = tcpc.GetStream();
if (stream.CanWrite)
{
byte[] code = new byte[3];
string str_code = "hhh";
code = Encoding.ASCII.GetBytes(str_code);
stream.Write(code, 0, code.Length);
}
}
catch (Exception e_client)
{
MessageBox.Show(e_client.Message);
}
c#写的,连接一个机子,总会报错:“由于目标机器积极拒绝,无法连接。”
请教版主和各位高手,到底哪出问题了?
PS:IP地址不会有错,连自己的机子也会出现上面的错误。