SelectMode SelectMode SelectMode SelectMode Enum

Definizione

Definisce le modalità di polling per il metodo 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
Ereditarietà

Campi

SelectError SelectError SelectError SelectError 2

Modalità stato di errore.Error status mode.

SelectRead SelectRead SelectRead SelectRead 0

Modalità stato di lettura.Read status mode.

SelectWrite SelectWrite SelectWrite SelectWrite 1

Modalità stato di scrittura.Write status mode.

Esempi

Nell'esempio seguente viene controllato lo stato di Socket un oggetto utilizzando SelectMode tutti e tre i valori di enumerazione.The following example checks the status of a Socket using all three SelectMode enumeration values. Una chiamata a Socket.Poll utilizzando il valore enumerato SelectWrite deve restituire 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 

Commenti

L' SelectMode enumerazione definisce le modalità Socket.Poll di polling che possono essere passate al metodo.The SelectMode enumeration defines the polling modes that can be passed to the Socket.Poll method. Usare il valore SelectRead per determinare se un'attesa Socket ha richieste di connessione in ingresso.Use the SelectRead value to determine if a listening Socket has incoming connection requests. Usare il valore SelectWrite per determinare se un Socket oggetto è scrivibile.Use the SelectWrite value to determine if a Socket is writeable. Usare il valore SelectError per determinare se è presente una condizione di errore in Socket.Use the SelectError value to determine if there is an error condition present on the Socket. Per una spiegazione della leggibilità, della leggibilità e della presenza di condizioni di errore, vedere il Socket.Poll metodo.For explanations of writeability, readability, and the presence of error conditions, see the Socket.Poll method.

Si applica a

Vedi anche