Socket.Blocking Socket.Blocking Socket.Blocking Socket.Blocking Property

定义

获取或设置一个值,该值指示 Socket 是否处于阻止模式。Gets or sets a value that indicates whether the Socket is in blocking mode.

public:
 property bool Blocking { bool get(); void set(bool value); };
public bool Blocking { get; set; }
member this.Blocking : bool with get, set
Public Property Blocking As Boolean

属性值

如果 Socket 将阻止,则为 true;否则为 falsetrue if the Socket will block; otherwise, false. 默认值为 trueThe default is true.

异常

尝试访问套接字时出错。An error occurred when attempting to access the socket.

注解

Blocking属性指示Socket是否处于阻止模式。The Blocking property indicates whether a Socket is in blocking mode.

如果你处于阻止模式,并且你进行了一个不会立即完成的方法调用,则应用程序将在请求的操作完成前阻止执行。If you are in blocking mode, and you make a method call which does not complete immediately, your application will block execution until the requested operation completes. 如果希望继续执行(即使请求的操作未完成),请将Blocking属性更改为。 falseIf you want execution to continue even though the requested operation is not complete, change the Blocking property to false. Blocking属性对异步方法不起作用。The Blocking property has no effect on asynchronous methods. 如果要以异步方式发送和接收数据,并想要阻止执行, ManualResetEvent请使用类。If you are sending and receiving data asynchronously and want to block execution, use the ManualResetEvent class.

备注

如果收到SocketException,请SocketException.ErrorCode使用属性获取特定的错误代码。If you receive a SocketException, use the SocketException.ErrorCode property to obtain the specific error code. 获取此代码后,请参阅Windows 套接字版本 2 API 错误代码文档,以获取有关错误的详细说明。After you have obtained this code, refer to the Windows Sockets version 2 API error code documentation for a detailed description of the error.

备注

当你在应用程序中启用网络跟踪后,此成员将输出跟踪信息。This member outputs trace information when you enable network tracing in your application. 有关详细信息,请参阅.NET Framework 中的网络跟踪For more information, see Network Tracing in the .NET Framework.

适用于