SelectMode 列挙型
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
Poll(Int32, SelectMode) メソッドのポーリング モードを定義します。
public enum class SelectMode
public enum SelectMode
type SelectMode =
Public Enum SelectMode
- 継承
名前 | 値 | 説明 |
---|---|---|
SelectError | 2 | エラー ステータス モード。 |
SelectRead | 0 | 読み取りステータス モード。 |
SelectWrite | 1 | 書き込みステータス モード。 |
次の例では、3 つのSelectMode列挙値をすべて使用して のSocket状態を確認します。 SelectWrite 列挙値を使用して を Socket.Poll 呼び出すと、 が返 true
されます。
//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.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 参照してください。
製品 | バージョン |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.3, 1.4, 1.6, 2.0, 2.1 |
.NET に関するフィードバック
.NET はオープンソース プロジェクトです。 フィードバックを提供するにはリンクを選択します。