SelectMode 列挙型

定義

Poll(Int32, SelectMode) メソッドのポーリング モードを定義します。

public enum class SelectMode
public enum SelectMode
type SelectMode = 
Public Enum SelectMode
継承
SelectMode

フィールド

名前 説明
SelectRead 0

読み取り状態モード。

SelectWrite 1

書き込み状態モード。

SelectError 2

エラー状態モード。

次の例では、3 つのSocket列挙値をすべて使用して、SelectModeの状態を確認します。 SelectWrite 列挙値を使用して Socket.Poll を呼び出すと、 trueが返されます。

//Creates the Socket for sending data over TCP.
Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream,
   ProtocolType.Tcp );

// Connects to host using IPEndPoint.
s.Connect(EPhost);
if (!s.Connected)
{
   strRetPage = "Unable to connect to host";
}
// Use the SelectWrite enumeration to obtain Socket status.
 if(s.Poll(-1, SelectMode.SelectWrite)){
      Console.WriteLine("This Socket is writable.");
 }
 else if (s.Poll(-1, SelectMode.SelectRead)){
       Console.WriteLine("This Socket is readable." );
 }
 else if (s.Poll(-1, SelectMode.SelectError)){
      Console.WriteLine("This Socket has an error.");
 }
'Creates the Socket for sending data over TCP.
Dim s As New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)

' Connects to host using IPEndPoint.
s.Connect(EPhost)
If Not s.Connected Then
   strRetPage = "Unable to connect to host"
End If
' Use the SelectWrite enumeration to obtain Socket status.
If s.Poll(- 1, SelectMode.SelectWrite) Then
   Console.WriteLine("This Socket is writable.")
Else
   If s.Poll(- 1, SelectMode.SelectRead) Then
      Console.WriteLine(("This Socket is readable. "))
   Else
      If s.Poll(- 1, SelectMode.SelectError) Then
         Console.WriteLine("This Socket has an error.")
      End If
   End If 
End If

注釈

SelectMode列挙型は、Socket.Poll メソッドに渡すことができるポーリング モードを定義します。 SelectRead 値を使用して、リッスンしている Socket が受信接続要求を持っているかどうかを判断します。 SelectWrite 値を使用して、 Socket が書き込み可能かどうかを判断します。 SelectError 値を使用して、 Socketにエラー条件があるかどうかを判断します。 書き込み可能性、読みやすさ、エラー条件の存在の説明については、 Socket.Poll メソッドを参照してください。

適用対象

こちらもご覧ください