locked
How to check the error code set by the connectasync method of datagramsocket?

    Question

  • Hi,

    How can i check the error code set by the connectasync method of the datagramsocket,

    I found the GetResult() of IAsycnAction but it doenot return any value.

    I also found the

    static SocketErrorStatus GetStatus( int hresult ) method but i dont know how to get the hresult.

    Please help

    Thanks

    AKEV

    Friday, December 14, 2012 1:46 PM

All replies

  • Try using following code..........

    task<void>( UdpSocket->ConnectAsync( ref new HostName(remoteHostName), remoteServiceName ) ).then([=] (task<void> previousTask)
        {
            try
            {
                previousTask.get();
                OutputDebugStringW(L"Connected \n");		
            }
            catch (Exception^ exception)
    
            {
    	    OutputDebugStringW(L"Connection Failed");
                OutputDebugStringW(exception->Message->Data());  // For HRESULT exception->HResult 
            }
        }).get();
    You can also use SocketError class in this purpose.


    Friday, December 14, 2012 2:43 PM
  • Yeah this will work but I have set the completed handler of the IAsyncAction so is there any way to find the result of the action inside that. 

    Monday, December 17, 2012 6:12 AM