UdpClient.EndSend(IAsyncResult) 메서드

정의

보류 중인 비동기 보내기를 끝냅니다.

public:
 int EndSend(IAsyncResult ^ asyncResult);
public int EndSend (IAsyncResult asyncResult);
member this.EndSend : IAsyncResult -> int
Public Function EndSend (asyncResult As IAsyncResult) As Integer

매개 변수

asyncResult
IAsyncResult

IAsyncResult를 호출할 때 반환되는 BeginSend 개체입니다.

반환

메서드가 성공할 경우 UdpClient에 보낸 바이트 수입니다.

예외

asyncResult이(가) null인 경우

BeginSend(Byte[], Int32, Int32, SocketFlags, AsyncCallback, Object) 메서드를 호출했지만 asyncResult가 반환되지 않은 경우

EndSend(IAsyncResult)가 비동기 읽기를 위해 이미 호출된 경우

내부 소켓에 액세스하려고 시도하는 동안 오류가 발생한 경우.

내부 Socket이 닫힌 경우

예제

다음 코드 예제에서는 를 사용하여 BeginSend 서버 요청의 비동기 보내기를 완료합니다.

public:
    static bool isMessageSent;

    static void SendCallback(IAsyncResult^ asyncResult)
    {
        UdpClient^ udpClient = (UdpClient^)asyncResult->AsyncState;

        Console::WriteLine("number of bytes sent: {0}",
            udpClient->EndSend(asyncResult));
        isMessageSent = true;
    }
public static bool messageSent = false;

public static void SendCallback(IAsyncResult ar)
{
    UdpClient u = (UdpClient)ar.AsyncState;

    Console.WriteLine($"number of bytes sent: {u.EndSend(ar)}");
    messageSent = true;
}

설명

이 메서드는 작업이 완료될 때까지 차단합니다.

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

적용 대상