开发者

How does one send ICMP packets (with associated TTL values) in Java on Android? Is it possible without a 3rd-party library? If not, what do you use?

This seems like it should be a simple solution to find, but I'm not having any luck. I want to write a simple ping/traceroute/dns troubleshooting app, but am simply not finding any documentation or examples on sending ICMP ECHO packets with set TTLs and interpreting their responses. I realize that Java likes to keep you away from "low-level" networking, but ICMP is a basic, major part of networking. Frankly, I'm shocked at the apparent difficulty. Am I making this more complicated than need be, or is there literally no good way to go about this? If the latter, in开发者_如何学Go what "bad" way do you most often work around this shortcoming?


Am I making this more complicated than need be, or is there literally no good way to go about this?

There is no pure-Java way to go about this. Java has never supported ICMP beyond its limited use in isReachable(), and I cannot even confirm that this use of ICMP exists in Android.

However, you could try to use the NDK to link in a C library that implements ICMP.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜