how to detect a carrier fail on ethernet by C code

Hi,

in fact all is in the subject.
I would like to detect if I have a carrier before to broadcast a message on the internet.
I know is it possible cause nicinfo returns such informations :wink: , but I would like to do the same thing in a program. So I donโ€™t know if such function does exist ? :unamused:
thanks.
Philippe.