简体   繁体   English

更改您从ping到IP地址的位置

[英]change location from where you ping to an IP address

My application is: ping host IP(in LAN) address from my machine. 我的应用程序是:从我的计算机ping主机IP(在LAN中)地址。

InetAddress address = InetAddress.getByName("host IP address");
 boolean b=(address.isReachable(10000));

When i run that web application ping is done from my machine so in my tomcat web server this application is running but is it possible to connect host ip address from my machine but i will put my application in another machine's tomact web server, which is also in my LAN. 当我运行该Web应用程序ping是从我的机器完成时,因此在我的tomcat Web服务器中该应用程序正在运行,但是可以从我的计算机连接主机ip地址,但是我会将我的应用程序放置在另一台计算机的tomact网络服务器中,在我的局域网中。 So ping will be done from my machine but another machine will run this application. 因此,将在我的计算机上执行ping操作,但另一台计算机将运行此应用程序。

Your tomcat application would need to know your machine's IP address ahead of time. 您的tomcat应用程序需要提前知道机器的IP地址。 You could use a Dynamic DNS server for this such as no-ip.com 您可以为此使用动态DNS服务器,例如no-ip.com。

Once you have a way of reliably knowing your machines IP from your server app you would need to write a small application to run on your machine that would accept a request from your server and actually do the ping and return the results. 一旦有了从服务器应用程序可靠地了解计算机IP的方法,就需要编写一个小型应用程序在计算机上运行,​​该应用程序将接受服务器的请求并实际执行ping操作并返回结果。

If you write this application in .net then you could use a WCF service configured as a SOAP endpoint on your local machine and have a method that does the ping and returns the ping output as a string. 如果使用.net编写此应用程序,则可以使用在本地计算机上配置为SOAP端点的WCF服务,并具有执行ping并将ping输出作为字符串返回的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM