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
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).
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).
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.