Skip to Main Content
C# Cookbook, 2nd Edition
book

C# Cookbook, 2nd Edition

by Jay Hilyard, Stephen Teilhet
January 2006
Intermediate to advanced content levelIntermediate to advanced
1184 pages
43h 23m
English
O'Reilly Media, Inc.
Content preview from C# Cookbook, 2nd Edition
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
920
|
Chapter 16: Networking
See Also
See the “Using SMTP for Outgoing Messages,” “SmtpMail Class,” “MailMessage
Class,” and “MailAttachment Class” topics in the MSDN documentation.
16.8 Check Out Your Network Connectivity
Problem
You need to determine the characteristics of the network adapters currently on the
machine.
Solution
Use the DisplayNICInfo method shown in Example 16-9 to display all of the charac-
teristics of the currently existing network adapters using the
System.Net.NetworkInformation.
NetworkInterface
class. Calling the GetAllNetworkInterfaces method will get the list
of current adapters as
NetworkInterface instances. Information such as the adapter
ID, MAC address, status, and NIC type is available on the
NetworkInterface class.
To see all of the IP information for an adapter, call the
GetIPProperties method on
the
NetworkAdapter instance and pass the IPInterfaceProperties collection to the
DisplayInterfaceProperties method (implemented shortly).
Example 16-9. DisplayNICInfo method
private static void DisplayNICInfo( )
{
//Display current network adapter states
NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces( );
Console.WriteLine("Network Adapter Information:");
foreach (NetworkInterface n in adapters)
{
Console.WriteLine("\tId: {0}", n.Id);
Console.WriteLine("\tPhysical ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

C# Cookbook

C# Cookbook

Joe Mayo
C# Cookbook

C# Cookbook

Stephen Teilhet, Jay Hilyard
Head First C#, 4th Edition

Head First C#, 4th Edition

Andrew Stellman, Jennifer Greene

Publisher Resources

ISBN: 0596100639Supplemental ContentCatalog PageErrata