SelectMode Sabit listesi

Tanım

Poll(Int32, SelectMode) yöntemi için yoklama modlarını tanımlar.

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

Alanlar

Name Değer Description
SelectRead 0

Okuma durumu modu.

SelectWrite 1

Yazma durumu modu.

SelectError 2

Hata durumu modu.

Örnekler

Aşağıdaki örnek, üç Socket numaralandırma değerinin de kullanıldığı bir SelectMode öğesinin durumunu denetler. SelectWrite numaralandırılmış değerini kullanmaya yapılan bir çağrı Socket.Poll döndürülmelidir true.

//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

Açıklamalar

Numaralandırma, SelectMode yöntemine geçirilebilen yoklama modlarını Socket.Poll tanımlar. Dinlemede Socket gelen bağlantı istekleri olup olmadığını belirlemek için SelectRead değerini kullanın. Yazılabilir olup olmadığını Socket belirlemek için SelectWrite değerini kullanın. üzerinde Socketbir hata koşulu olup olmadığını belirlemek için SelectError değerini kullanın. Yazılabilirlik, okunabilirlik ve hata koşullarının varlığıyla ilgili açıklamalar için yöntemine Socket.Poll bakın.

Şunlara uygulanır

Ayrıca bkz.