C# 插座未与IPEndPoint连接

C# 插座未与IPEndPoint连接,c#,networking,C#,Networking,我有一个连接到后端的System.Net.Sockets.Socket public class Connection { private readonly Socket _client; private readonly IPEndPoint _endPoint; byte[] _sendBuf = new byte[0x1000]; protected Connection(string host, int port) { var

我有一个连接到后端的
System.Net.Sockets.Socket

public class Connection
{
    private readonly Socket _client;
    private readonly IPEndPoint _endPoint;

    byte[] _sendBuf = new byte[0x1000];

    protected Connection(string host, int port)
    {
        var ipAddress = IPAddress.Parse(host);
        _endPoint = new IPEndPoint(ipAddress, port);
        _client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
    }

    protected void Connect()
    {
        //Fails
        _client.Connect(_endPoint);
    }
}
套接字尝试连接,但在调用
connect
函数时超时。但是,如果我向
套接字提供
主机
端口
参数,则连接
函数而不是
IPEndPoint
,它将成功连接

    protected void Connect()
    {
        //Connects
        _client.Connect(host, port);    //same as used in creating IPEndPoint above
    }

为什么??我试图连接的端点位于VPN中,与我所在的网络相连。

你能提供套接字的详细信息吗?@ArijitMukherjee:你是说端点的详细信息吗?它是VPN中的一个地址。不,我的意思是你使用的是哪个套接字,就像市场上有不同的套接字一样。@ArijitMukherjee:
System.Net.sockets.Socket
主机解析为什么(解析返回哪个IP)?解析前的主机字符串是什么?