【发布时间】:2014-06-10 18:33:06
【问题描述】:
我试图监听 ip 地址 10.100.102.3 ,但是 VS 2013 报错:
“请求的地址在此上下文中无效”。
我的 IP 地址是 10.100.102.7。
代码:
IPEndPoint localEndPoint = new IPEndPoint(IPAddress.Parse("10.100.102.3"), Port);
listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
listener.Bind(localEndPoint);
listener.Listen(100);
Receiver = listener.Accept();
【问题讨论】:
-
您定义在上收听的IP地址,而不是收听的IP地址。即您需要提供 LocalEndPoint。
-
非常感谢。
标签: c# .net sockets networking network-programming