开发者

how to use "system call" to determine ethernet status on linux?

开发者 https://www.devze.com 2023-01-17 10:06 出处:网络
usually I use ping to det开发者_如何学Cermine ethernet status, like: ping -c 1 -w 1 <ip_addr>

usually I use ping to det开发者_如何学Cermine ethernet status, like:

ping -c 1 -w 1 <ip_addr>

how could we use system call to determine ethernet status? and how could we embedded this method in java codes?


ping doesn't determine ethernet status; it sends a packet and waits for a response, so it is used to end-to-end test a network.

You can of course write your own ping, there are plenty of examples on the internet. Under Linux you generally need to be root to use the type of sockets required.

If you do genuinely just want to determine whether the link is active, have a look at the output of

ip link sh 
0

精彩评论

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