Reputation: 507
usually I use ping to determine 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?
Upvotes: 0
Views: 720
Reputation: 63616
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
Upvotes: 1