Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29276 Discussions

How to determine whether computer is connected to a LAN

michael_green
Beginner
721 Views

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

0 Kudos
3 Replies
jimdempseyatthecove
Honored Contributor III
721 Views
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
0 Kudos
Steven_L_Intel1
Employee
721 Views
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).
0 Kudos
Paul_Curtis
Valued Contributor I
721 Views
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.
0 Kudos
Reply