SelectMode Enumeration
Defines the polling modes for the Socket.Poll method.
[Visual Basic] <Serializable> Public Enum SelectMode [C#] [Serializable] public enum SelectMode [C++] [Serializable] __value public enum SelectMode [JScript] public Serializable enum SelectMode
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 writeablity, readability, and the presence of error conditions, see the Socket.Poll method.
Members
| Member name | Description |
|---|---|
| SelectError Supported by the .NET Compact Framework. | Error status mode. |
| SelectRead Supported by the .NET Compact Framework. | Read status mode. |
| SelectWrite Supported by the .NET Compact Framework. | Write status mode. |
Example
[Visual Basic, C#, C++] 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.
[Visual Basic] '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 should not print. Because this is not a listening Socket," + " no incoming connecton requests are expected. ")) Else If s.Poll(- 1, SelectMode.SelectError) Then Console.WriteLine("This Socket has an error.") End If End If [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 should not print. Because this is not a listening Socket," + " no incoming connecton requests are expected. " ); } else if (s.Poll(-1, SelectMode.SelectError)){ Console.WriteLine("This Socket has an error."); } [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 = S"Unable to connect to host"; } // Use the SelectWrite enumeration to obtain Socket status. if (s->Poll(-1, SelectMode::SelectWrite)) { Console::WriteLine(S"This Socket is writable."); } else if (s->Poll(-1, SelectMode::SelectRead)) { Console::WriteLine(S"This should not print. Because this is not a listening Socket, " S" no incoming connecton requests are expected."); } else if (s->Poll(-1, SelectMode::SelectError)) { Console::WriteLine(S"This Socket has an error."); }
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Namespace: System.Net.Sockets
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework
Assembly: System (in System.dll)