locked
Stream Socket Exception RRS feed

  • Question

  •    while (connctionestablished == false)
                {

                    try
                    {
                        await InterntSocket.ConnectAsync(ConnectSettings);
                        connctionestablished = true;
                    }
                    catch (Exception exception)
                    {
                        connctionestablished = false;
                        var message = SocketError.GetStatus(exception.HResult);
                        ConnectionStatus.Text = message.ToString();
                    }
                }

    For some strange reason my exception handler is very inconsistent when catching exceptions.  Sometimes it catches it, sometimes it doesn't can anyone see why.

                    
    Saturday, January 25, 2014 10:35 PM

Answers

  • Hi,

    Your codes seem to be right. And the ConnectAsync(HostName, String) method throws an exception if a TCP connection could not be established with the network server. So if the connection  established successfully,you cannot catch the exceptions. You can see Connecting with a stream socket  to get more information.

    Best Wishes!


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey. Thanks<br/> MSDN Community Support<br/> <br/> Please remember to &quot;Mark as Answer&quot; the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.


    • Edited by Anne Jing Monday, January 27, 2014 6:56 AM edit
    • Marked as answer by Anne Jing Monday, February 10, 2014 1:41 AM
    Monday, January 27, 2014 6:55 AM