0

I have two computers, a server(192.168.173.1) and a client(192.168.173.2) connected via Ethernet cable and configured with static ips. On the other hand they are both connected to the same wifi network (dynamic ip).

When I ping the client from the server using the command line ("ping 192.168.173.2") I get an instant reply. But when the code pings using the code below

Ping pinger = new Ping();
PingReply reply = pinger.Send(ConfigurationManager.AppSettings["ClientTablet.Ip"]);
        return (reply.Status == IPStatus.Success);

I get TimeOut as reply.Status.

If I disconnect the server from wifi and run the c# pinger again. I get a proper response.

Why having the wifi on results in this behavior?

Alejandro Lozdziejski
  • 1,063
  • 4
  • 12
  • 30
  • The `Ping` class and the `ping` command you are using could both be "choosing" which local ip to bind to (say via `Socket.Bind()`). The `ping` class may be choosing the wireless local ip, and the `ping` command may be choosing the ethernet ip. Can the `Ping` class be configured, in terms of what local ip it binds to (other constructors/methods/parameters)? – DWright Aug 28 '16 at 00:00

1 Answers1

0

As stated in using System.Net.NetworkInformation, is there a way to bind a ping to a specific interface? you should check your routing tables. You can do that by typing

route print

in your console.

Community
  • 1
  • 1
Santiago
  • 51
  • 6