SelectMode 열거형

정의

Poll(Int32, SelectMode) 메서드에 대한 폴링 모드를 정의합니다.

public enum class SelectMode
public enum SelectMode
type SelectMode = 
Public Enum SelectMode
상속
SelectMode

필드

SelectError 2

오류 상태 모드입니다.

SelectRead 0

읽기 상태 모드입니다.

SelectWrite 1

쓰기 상태 모드입니다.

예제

다음 예제에서는 세 SelectMode 개의 열거형 값을 모두 사용하여 상태를 Socket 확인합니다. SelectWrite 열거형 값을 사용하는 호출 Socket.Poll 은 반환 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

설명

열거형은 SelectMode 메서드에 전달할 수 있는 폴링 모드를 Socket.Poll 정의합니다. SelectRead 값을 사용하여 수신 대기 Socket 에 들어오는 연결 요청이 있는지 확인합니다. SelectWrite 값을 사용하여 쓰기 가능한지 확인 Socket 합니다. SelectError 값을 사용하여 에 오류 조건이 Socket있는지 확인합니다. 쓰기 가능성, 가독성 및 오류 조건의 존재에 대한 설명은 메서드를 Socket.Poll 참조하세요.

적용 대상

추가 정보