Showing posts with label Network Example In C sharp. Show all posts
Showing posts with label Network Example In C sharp. Show all posts

Saturday, April 16, 2011

Network Example In C sharp


Network Example In C sharp
Developing applications in C# that access resource on the internet is easy. This post shows four useful functions: checking if the PC is connected to a network, domain name to IP address lookup, ping a host and download a file.



Network Availability

You can check if there are any network connections using NetworkInterface.GetIsNetworkAvailable static method, found in the System.Net.NetworkInformation assembly. MSDN: “A network connection is considered to be available if any network interface is marked “up” and is not a loopback or tunnel interface.” Here is how you could check for a network connection:
1.         if (!System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable())  
2.         {  
3.             MessageBox.Show("There is no network connection available.",  
4.                 "NetworkTools", MessageBoxButtons.OK, MessageBoxIcon.Information);  
5.         }  

Host Name Lookup


To lookup a host name’s IP address or vice versa you could use the Dns.GetHostEntry static method in the System.Net assembly. It returns an IPHostEntry object th

AngularJS Basics - Part 1

                                                                  AngularJS What is AngularJS ·          Framework by googl...