网络编程
TcpClient tcp = new TcpClient();
IPAddress ip = IPAddress.Parse("192.168.0.1");
//IPAddress ip = IPAddress.Any;
IPEndPoint ipPoint = new IPEndPoint(ip, 12000);
TcpListener lis = new TcpListener(ipPoint);
lis.Start();<-在这里显示“在其上下文中,该请求的地址无效”错误
tcp = lis.AcceptTcpClient();
if (tcp.Connected)
{
string str="发送的数据";
NetworkStream stream = tcp.GetStream();
byte[] by = System.Text.Encoding.Unicode.GetBytes(str.ToCharArray());
stream.Write(by, 0, by.Length);
stream.Flush();
}
我把电脑的ip地址设置成192.168.0.1,但还是不行,请问是为什么啊?