How can I programmatically check whether my machine has internet access or not using C/C++, is it just a matter of pinging an IP? How does NIC do it ? I mean something like
There is nothing of that sort I think, but you can try this:
The easiest way is to try to connect to a known outside IP address.
If it fails in Windows, the connect function will return SOCKET_ERROR, and WSAGetLastError will usually return WSAEHOSTUNREACH (meaning the packet couldn't be sent to the host).
In Linux, you'll get back a -1, and errno will be ENETUNREACH.
Some useful links:
1. Link for Windows Sockets
2. Link for Linux/Unix sockets