Project Home
Project Home
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - How to tell if ethernet cable is unplugged?: (3 Items)
   
How to tell if ethernet cable is unplugged?  
How do I programmatically detect if the Ethernet cable has been unplugged?  I tried the ioctl SIOCGIFFLAGS command to 
look at the IFF_UP and IFF_RUNNING flags, but these are always set.  ifconfig seems to know because when the cable is 
plugged in, it displays:

  status: active

Since the source code is nearly impossible to access, I can't see how it knows.  Does anyone know the magic function to 
determine this?
Re: How to tell if ethernet cable is unplugged?  
IFM_STATUS_DESC(ifms, bit)

in net/if_media.h should do what you need.

And the ioctl you need is SIOCGIFMEDIA.



On 04/03/2013 03:50 PM, Robert Murrell wrote:
> How do I programmatically detect if the Ethernet cable has been unplugged?  I tried the ioctl SIOCGIFFLAGS command to 
look at the IFF_UP and IFF_RUNNING flags, but these are always set.  ifconfig seems to know because when the cable is 
plugged in, it displays:
>
>    status: active
>
> Since the source code is nearly impossible to access, I can't see how it knows.  Does anyone know the magic function 
to determine this?
>
>
>
> _______________________________________________
>
> Networking Drivers
> http://community.qnx.com/sf/go/post100294
> To cancel your subscription to this discussion, please e-mail drivers-networking-unsubscribe@community.qnx.com

Re: How to tell if ethernet cable is unplugged?  
Thank you sir, this is what I was looking for.