C# TCP Listener on External IP address - Can not establish connection


  • I am using Visual Studio 2013, C#.  Static IP on my PC is: and my instrument's ip address is

    I can ping the instrument, but in C# TCP Listener or in Socket programming, it binds only internal Client's IP address (LocalIpAddress) on the same Machine, kind of loop back. Kindly provide suggestions. Thank you in advance. 

    • Moved by Richard MuellerMVP Wednesday, April 26, 2017 11:51 PM Not a TechNet Wiki question
    Wednesday, April 26, 2017 9:24 PM

All replies

  • You have asked in the wrong forum. This forum is for questions and discussions about the TechNet Wiki. I will move this question to a more appropriate forum.

    Richard Mueller - MVP Enterprise Mobility (Identity and Access)

    Wednesday, April 26, 2017 11:49 PM
  • Hi D_Dave,

    Thank you for posting here.

    For your question, maybe the firewall could not pass the external IP address through to the internal IP address via Port Forwarding. Here is three ways to modify the firewall configuration. Please refer to the threads in SO.

    Based on my search, when you could connect over internet, you could setup Port Forwarding on router. You would like to check the thread in SO.

    I hope this would be helpful.

    Best Regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Thursday, April 27, 2017 8:45 AM
  • Is there some confusion?

    You use TcpClient.Connect() to connect to another machine/device, and use TcpListener for waiting incoming connection. So it's kind of normal that TCP Listener will bind to local address only.

    Thursday, April 27, 2017 9:50 AM
  • Thank you for the answer. I got your point.

    I have modified my code. At PC side, I am running TCP Client code that tries to connect with Server i.e. Instrument in this case with IP: and its port number. 

    I tried port forwarding but still it couldn't establish connection with Instrument, though I could ping my instrument's ip. 

    Monday, May 8, 2017 9:08 PM
  • Try use PuTTY or Windows Telnet client (in Vista or above, need to be installed via enabling Windows Features "Telnet Client", after that, you can use "telnet" command) to ensure you can connect to the port of remote server. (So the server side is up, and there's no firewall blocking the port or the firewall is set to allow that port)
    Monday, May 8, 2017 11:05 PM
  • FYI, since both computer are on the same subnet, the suggestion on port forwarding is not applicable.
    Monday, May 8, 2017 11:07 PM