Listing 5.10 Get an IP address through an index
1: Using system.net; 3: 4: Class resolvedns5: {6: ipaddress [] m_arrips; 7:8: public void resolve (string strhost) 9: {10: iphostentry iphe = DNS.GETHOSTBYNAME Strhost); 11: m_arrips = iphe.addressList; 12:} 13: 14: Public ipaddress this [int NINDEX] 15: {16: get17: {18: Return M_Arrips [NINDEX]; 19:} 20:} 21: 22 : Public int count23: {24: get {return m_arrips.Length;} 25:} 26:} 27: 28: Class DNSRESOLVERAPP29: {30: public static void main () 31: {32: resolvedns myDnsResolver = new resolvedns () ; 33: MyDNSResolver.resolve ("http://www.microsoft.com"); 34: 35: Int ncount = mydnsResolver.count; 36: console.writeline ("Found {0} ip's for hostname", ncount); 37: for (int i = 0; i Compiler Environment: Visual Studio .Net2003 Version 7.1.3091 Microsoft Visual C # .NET Microsoft .NET Framework Version 1.1.4322 SP1 The generated EXE file, after execution error: Unprocessed "System.Net.Sockets.socketexception" types of exceptions appear in System.dll. Additional Information: The Requested Name Is Valid and Was Found in The Database, But It Does Not Have The Correct Associated Data Being Resolved for Why is this? ......