How to determine whether computer is connected to a LAN

How to determine whether computer is connected to a LAN

Hi All,

I have an application that needs to determine whether the PC it is running on is connected to a LAN. Does anyone have a snippet of Fortran code that can do this?

With many thanks in advance

Mike

4 Beiträge / 0 neu
Letzter Beitrag
Nähere Informationen zur Compiler-Optimierung finden Sie in unserem Optimierungshinweis.

This is not subject matter for this forum.

If this is a Windows application then consult MSDN. After you find a C/C++ example then see if the necessary function interfaces are available in IFWIN... modules. If not, then you will have to declare the appropriate interface blocks (looking at IFWIN... headers for guidance).

If this is a Linux applicaiton then consult the appropriate documentation for a C/C++ example then see if the necessary function interfaces are available in IF???... modules. If not, then you will have to declare the appropriate interface blocks (looking at IF???... headers for guidance).

Jim Dempsey

www.quickthreadprogramming.com

I suppose the real question is "what do you mean by 'connected to a LAN'? You can find out if there is an IP address, but that doesn't really tell you if the system is connected to anything else. What are you going to do with the information? It can get especially tricky as the system may have more than one network adapter, and these might be connected to separate networks (or not connected at all).

Steve

Sample Fortran code using Win32 API fucntions to find the IP and MAC addresses for all installed network adapters was posted here back in December: http://software.intel.com/en-us/forums/topic/280504. Having a valid IP address would certainly be a precondition for the availability of network communications. Suggest you check MSDN for other API functions, since the opsys certainly knows when a network is available.

Melden Sie sich an, um einen Kommentar zu hinterlassen.