locked
Application says StreamSocketListener is listening but does not appear on netstat

    Question

  • I have an Windows 8.1 application running on my PC that should listen to a port, chosen by the application itself. When I run the application, it says is listening to the port x, but when I try to find it on netstat, it is simply not there. Any thoughts?

            private async void StartListener(object sender, RoutedEventArgs e)
            {
                if (listening)
                {
                    NotifyUser("Listening", NotifyType.StatusMessage);
                    return;
                }
    
                StreamSocketListener listener = new StreamSocketListener();
                listener.ConnectionReceived += OnConnection;
    
                try
                {
                    await listener.BindServiceNameAsync(String.Empty);
                    NotifyUser("Listening to port " + listener.Information.LocalPort, NotifyType.StatusMessage);
                }
                catch (Exception exception)
                {
                    if (SocketError.GetStatus(exception.HResult) == SocketErrorStatus.Unknown)
                    {
                        throw;
                    }
    
                    NotifyUser("Start listening failed with error: " + exception.Message, NotifyType.ErrorMessage);
                }
            }

    Wednesday, April 16, 2014 10:51 PM

Answers

  • Hi lucas,

    Sorry I cannot reproduce the issue that you are facing.

    I have the app and I set a breakpoint right after the app create a socket listener, I can see my port 4317 has been used. After that I open the CMD and type the netstat -a as the command.

    I'm wondering if your app has been terminated when you type the netstat, or could you share us a reproducible steps to see your question.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" 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.

    • Marked as answer by lucasmoraes90 Thursday, April 17, 2014 11:18 AM
    Thursday, April 17, 2014 8:01 AM
    Moderator

All replies

  • Hi lucas,

    Sorry I cannot reproduce the issue that you are facing.

    I have the app and I set a breakpoint right after the app create a socket listener, I can see my port 4317 has been used. After that I open the CMD and type the netstat -a as the command.

    I'm wondering if your app has been terminated when you type the netstat, or could you share us a reproducible steps to see your question.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" 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.

    • Marked as answer by lucasmoraes90 Thursday, April 17, 2014 11:18 AM
    Thursday, April 17, 2014 8:01 AM
    Moderator
  • Thanks for your reply. I got it!

    Thursday, April 17, 2014 10:11 AM