SslStream.EndWrite(IAsyncResult) 메서드

정의

이전에 BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object)를 호출하여 시작한 비동기 쓰기 작업을 끝냅니다.

public:
 override void EndWrite(IAsyncResult ^ asyncResult);
public override void EndWrite (IAsyncResult asyncResult);
override this.EndWrite : IAsyncResult -> unit
Public Overrides Sub EndWrite (asyncResult As IAsyncResult)

매개 변수

asyncResult
IAsyncResult

IAsyncResult를 호출했을 때 반환되는 BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object) 인스턴스입니다.

예외

asyncResult이(가) null인 경우

BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object)를 호출했지만 asyncResult가 만들어지지 않은 경우

완료할 보류 상태의 쓰기 작업이 없는 경우.

또는

인증이 수행되지 않은 경우.

쓰기 작업이 실패했습니다.

예제

다음 코드 예제에서는 비동기 쓰기 작업을 종료하는 방법을 보여 줍니다.

void WriteCallback( IAsyncResult^ ar )
{
   ClientState^ state = dynamic_cast<ClientState^>(ar->AsyncState);
   SslStream^ stream = state->stream;
   try
   {
      Console::WriteLine( L"Writing data to the client." );
      stream->EndWrite( ar );
   }
   catch ( Exception^ writeException ) 
   {
      Console::WriteLine( L"Write error: {0}", writeException->Message );
      state->Close();
      return;
   }

   Console::WriteLine( L"Finished with client." );
   state->Close();
}
void WriteCallback(IAsyncResult ar)
{
    ClientState state = (ClientState) ar.AsyncState;
    SslStream stream = state.stream;
    try
    {
        Console.WriteLine("Writing data to the client.");
        stream.EndWrite(ar);
    }
    catch (Exception writeException)
    {
        Console.WriteLine("Write error: {0}",
            writeException.Message);
        state.Close();
        return;
    }
    Console.WriteLine("Finished with client.");
    state.Close();
}

설명

작업이 완료되지 않은 경우 이 메서드는 작업이 완료될 때까지 차단합니다.

사용자가 성공적으로 인증 될 때까지 애플리케이션에서이 메서드를 호출할 수 없습니다. 인증하려면 , 또는 BeginAuthenticateAsClient, AuthenticateAsServerBeginAuthenticateAsServer 메서드 중 AuthenticateAsClient하나를 호출합니다.

이 작업을 동기적으로 수행하려면 메서드를 Write 사용합니다.

적용 대상