SelectMode Enumeration
Definition
Definiert die Abrufmodi für die Poll(Int32, SelectMode)-Methode.Defines the polling modes for the Poll(Int32, SelectMode) method.
public enum class SelectMode
public enum SelectMode
type SelectMode =
Public Enum SelectMode
- Vererbung
Felder
SelectError | 2 | Fehlerstatusmodus.Error status mode. |
SelectRead | 0 | Lesestatusmodus.Read status mode. |
SelectWrite | 1 | Schreibstatusmodus.Write status mode. |
Beispiele
Im folgenden Beispiel wird der Status eines Socket mit allen drei SelectMode Enumerationswerten überprüft.The following example checks the status of a Socket using all three SelectMode enumeration values. Ein-Befehl Socket.Poll , der den SelectWrite-Enumerationswert verwendet, sollte zurückgeben. true
A call to Socket.Poll using the SelectWrite enumerated value should return 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
Hinweise
Die SelectMode -Enumeration definiert die Abruf Modi, die an die Socket.Poll -Methode übermittelt werden können.The SelectMode enumeration defines the polling modes that can be passed to the Socket.Poll method. Verwenden Sie den SelectRead-Wert, um zu Socket bestimmen, ob ein lauschen über eingehende Verbindungsanforderungen verfügt.Use the SelectRead value to determine if a listening Socket has incoming connection requests. Verwenden Sie den SelectWrite-Wert, um Socket zu bestimmen, ob ein beschreibbar ist.Use the SelectWrite value to determine if a Socket is writeable. Verwenden Sie den SelectError-Wert, um zu bestimmen, ob eine Fehlerbedingung Socketin vorhanden ist.Use the SelectError value to determine if there is an error condition present on the Socket. Erläuterungen zur Beschreib barkeit, Lesbarkeit und zum vorhanden sein von Fehlerbedingungen finden Sie unter der Socket.Poll -Methode.For explanations of writeability, readability, and the presence of error conditions, see the Socket.Poll method.