我得到了下面的代码:的TcpClient抛出SocketException
public static readonly IPEndPoint RootNode = new IPEndPoint(IPAddress.Parse("213.226.18.82"), 8333);
public static void Main(string[] args)
{
TcpClient tcpClient = new TcpClient(RootNode);
}
这将引发与消息The requested address is not valid in its context
一个SocketException
。 现在什么奇怪的是,此代码:
public static readonly IPEndPoint RootNode = new IPEndPoint(IPAddress.Parse("213.226.18.82"), 8333);
public static void Main(string[] args)
{
TcpClient tcpClient = new TcpClient();
tcpClient.Connect(RootNode);
}
的区别是什么吗?
连接有两个端点。本地和远程。第一个代码应该设置一个本地端点,而第二个代码设置远程端点。 – jdweng