SelectMode Enumeration

Defines the polling modes for the Socket.Poll method.

Namespace:  System.Net.Sockets
Assembly:  System (in System.dll)

'Declaration
Public Enumeration SelectMode

Member nameDescription
SelectErrorError status mode.
SelectReadRead status mode.
SelectWriteWrite status mode.

The SelectMode enumeration defines the polling modes that can be passed to the Socket.Poll method. Use the SelectRead value to determine if a listening Socket has incoming connection requests. Use the SelectWrite value to determine if a Socket is writeable. Use the SelectError value to determine if there is an error condition present on the Socket. For explanations of writeability, readability, and the presence of error conditions, see the Socket.Poll method.

The following example checks the status of a Socket using all three SelectMode enumeration values. A call to Poll using the SelectWrite enumerated value should return 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 Socket is readable. "))
   Else 
      If s.Poll(- 1, SelectMode.SelectError) Then
         Console.WriteLine("This Socket has an error.")
      End If 
   End If  
End If

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft