SocketAsyncEventArgs.ConnectByNameError 属性

定义

当使用 DnsEndPoint 时,在出现连接故障的情况下获取异常。

public:
 property Exception ^ ConnectByNameError { Exception ^ get(); };
public Exception ConnectByNameError { get; }
public Exception? ConnectByNameError { get; }
member this.ConnectByNameError : Exception
Public ReadOnly Property ConnectByNameError As Exception

属性值

Exception

一个 Exception,指示在为 DnsEndPoint 属性指定 RemoteEndPoint 时发生连接错误的原因。

注解

如果为RemoteEndPoint属性指定了连接失败DnsEndPoint,该ConnectByNameError属性将包含指示套接字错误的详细原因的异常。

为属性指定并IPEndPoint发生连接失败时,该ConnectByNameError属性将是引用nullRemoteEndPoint

当连接失败时,始终 SocketError 设置该属性。 如果该属性是连接到 a DnsEndPoint的失败,则此属性ConnectByNameError包含有关失败的详细信息。 如果应用程序仅对连接操作成功还是失败感兴趣,则应用程序只需要检查 SocketError 属性。

适用于

另请参阅