Piyumi Guruge Piyumi Guruge - 4 months ago 16
C Question

Is there any library functions in C to check the Internet connection?

Can you give me a simplest method to check the Internet availability using a C program in Linux?

I have tried with the

internetCheckConnection()
, But it doesn't work well.

Answer Source

Short answer: no. Neither C nor C++ has direct knowledge of networking, or any built-in networking functions.

Depending on what 3rd-party libraries you are using, there may be something you can use, but that depends on the library, it isn't directly part of C.

I can imagine there are libraries out there that might try to ping some internal/external address, perform a name lookup, etc. But if you're on an isolated network, not having the ability to ping, lookup, or cross a firewall to get to a certain location may be perfectly valid, and doesn't indicate a networking problem.