SelectMode 列挙体
アセンブリ: System (system.dll 内)

Public Enumeration SelectMode


SelectMode 列挙体は、Socket.Poll メソッドに渡すことができるポーリング モードを定義します。SelectRead 値を使用して、待機している Socket が受信接続を要求しているかどうかを確認します。SelectWrite 値を使用して、Socket が書き込み可能かどうかを確認します。SelectError 値を使用して、Socket にエラー条件が存在するかどうかを確認します。書き込み機能、読み取り機能、およびエラー条件の存在についての説明は、Socket.Poll メソッドのトピックを参照してください。

SelectMode 列挙体の 3 つの値をすべて使用して、Socket のステータスをチェックする例を次に示します。SelectWrite 列挙値を使用して Poll を呼び出すと、true が返されます。
'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
//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. Socket^ s = gcnew 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. Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream , ProtocolType.Tcp); // Connects to host using IPEndPoint. s.Connect(epHost); if (!(s.get_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 should not print." + "Because this is not a listening Socket," + " no incoming connecton requests are expected. "); } else { if (s.Poll(-1, SelectMode.SelectError)) { Console.WriteLine("This Socket has an error."); } } }

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- SelectMode 列挙体のページへのリンク