SelectMode SelectMode SelectMode SelectMode Enum

Definición

Define los modos de sondeo del método Poll(Int32, SelectMode).Defines the polling modes for the Poll(Int32, SelectMode) method.

public enum class SelectMode
public enum SelectMode
type SelectMode = 
Public Enum SelectMode
Herencia

Campos

SelectError SelectError SelectError SelectError 2

Modo de estado de error.Error status mode.

SelectRead SelectRead SelectRead SelectRead 0

Modo de estado de lectura.Read status mode.

SelectWrite SelectWrite SelectWrite SelectWrite 1

Modo de estado de escritura.Write status mode.

Ejemplos

En el ejemplo siguiente se comprueba el estado de un Socket usa las tres SelectMode valores de enumeración.The following example checks the status of a Socket using all three SelectMode enumeration values. Una llamada a Socket.Poll utilizando el valor enumerado de SelectWrite debe devolver 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 

Comentarios

El SelectMode enumeración define los modos de sondeo que se pueden pasar a la Socket.Poll método.The SelectMode enumeration defines the polling modes that can be passed to the Socket.Poll method. Use el valor de SelectRead para determinar si una escucha Socket tiene solicitudes de conexión entrantes.Use the SelectRead value to determine if a listening Socket has incoming connection requests. Utilice el valor SelectWrite para determinar si un Socket es grabable.Use the SelectWrite value to determine if a Socket is writeable. Use el valor de SelectError para determinar si hay una condición de error presente en el Socket.Use the SelectError value to determine if there is an error condition present on the Socket. Para obtener una explicación de la presencia de las condiciones de error, la legibilidad y permiten la escritura, consulte el Socket.Poll método.For explanations of writeability, readability, and the presence of error conditions, see the Socket.Poll method.

Se aplica a

Consulte también: