Edit

Share via


SelectMode Enum

Definition

Defines the polling modes for the Poll(Int32, SelectMode) method.

C#
public enum SelectMode
Inheritance
SelectMode

Fields

Name Value Description
SelectRead 0

Read status mode.

SelectWrite 1

Write status mode.

SelectError 2

Error status mode.

Examples

The following example checks the status of a Socket using all three SelectMode enumeration values. A call to Socket.Poll using the SelectWrite enumerated value should return true.

C#
//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.");
 }

Remarks

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.

Applies to

Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.3, 1.4, 1.6, 2.0, 2.1

See also