4

I have a server app i'm playing with. I bind the address to 127.0.0.1 and it was fine until i wanted to connect from a client inside a VM. So i bind it to 192... Well now my test which all connect to 127... can't connect. I know i could use Any but i don't want the outside internet connecting (I know i could use firewalls but ATM i dont want to).

Is there a way i can specify any local address so 192.x.x.x and 127.0.0.3 work?

1 Answers1

7

When specifying your local address, use IPAddress.Any instead of an explicit address. See the previously answered question, too: TcpListener: How to listen on specific port on all interfaces?

Community
  • 1
  • 1
Kevin Mangold
  • 1,167
  • 8
  • 21
  • 1
    If that host is accessible from outside, then yes. You could set up two TcpListeners, one for 192.x.x.x and another from 127.0.0.1. – Kevin Mangold Aug 12 '12 at 18:02
  • How would i setup 192.x.x.x (and 127.x.x.x)? –  Aug 12 '12 at 18:04
  • 1
    @acidzombie24 see my previous comment. You would need 2 TcpListener objects, one for each ip address. Upon receiving an incoming request, send them to the same handler. – Kevin Mangold Aug 12 '12 at 18:08