SelectMode 列挙体とは? わかりやすく解説

SelectMode 列挙体

Socket.Poll メソッドポーリング モード定義します

名前空間: System.Net.Sockets
アセンブリ: System (system.dll 内)
構文構文

public enum SelectMode
public enum class SelectMode
public enum SelectMode
public enum SelectMode
メンバメンバ
解説解説
使用例使用例

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.");
        }
    }
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
System.Net.Sockets 名前空間
Socket.Poll
Select



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「SelectMode 列挙体」の関連用語

SelectMode 列挙体のお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



SelectMode 列挙体のページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS