Socket.Poll メソッドのポーリング モードを定義します。
<Serializable>
Public Enum SelectMode
[C#]
[Serializable]
public enum SelectMode
[C++]
[Serializable]
__value public enum SelectMode
[JScript]
public
Serializable
enum SelectMode
解説
SelectMode 列挙体は、 Socket.Poll メソッドに渡すことができるポーリング モードを定義します。 SelectRead 値を使用して、待機している Socket が受信接続を要求しているかどうかを確認します。 SelectWrite 値を使用して、 Socket が書き込み可能かどうかを確認します。 SelectError 値を使用して、 Socket にエラー条件が存在するかどうかを確認します。書き込み機能、読み取り機能、およびエラー条件の存在についての説明は、 Socket.Poll メソッドのトピックを参照してください。
メンバ
メンバ名 | 説明 |
---|---|
SelectError
.NET Compact Framework でもサポート。 |
エラー ステータス モード。 |
SelectRead
.NET Compact Framework でもサポート。 |
読み取りステータス モード。 |
SelectWrite
.NET Compact Framework でもサポート。 |
書き込みステータス モード。 |
使用例
[Visual Basic, C#, C++] 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 should not print. Because this is not a listening Socket," + " no incoming connecton requests are expected. "))
Else
If s.Poll(- 1, SelectMode.SelectError) Then
Console.WriteLine("This Socket has an error.")
End If
End If
[C#]
//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 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.");
}
[C++]
//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 = S"Unable to connect to host";
}
// Use the SelectWrite enumeration to obtain Socket status.
if (s->Poll(-1, SelectMode::SelectWrite)) {
Console::WriteLine(S"This Socket is writable.");
} else if (s->Poll(-1, SelectMode::SelectRead)) {
Console::WriteLine(S"This should not print. Because this is not a listening Socket, "
S" no incoming connecton requests are expected.");
} else if (s->Poll(-1, SelectMode::SelectError)) {
Console::WriteLine(S"This Socket has an error.");
}
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
名前空間: System.Net.Sockets
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET
アセンブリ: System (System.dll 内)