/// <summary>Main()</summary> public static void Main ( string[] argv ) { Boolean booleanParseCommandLineArguments = false; string exceptionMessage = null; StringBuilder[][] sb = null; UtilityWhoIsPort43Argument utilityWhoIsArgument = null; utilityWhoIsArgument = new UtilityWhoIsPort43Argument(); booleanParseCommandLineArguments = UtilityParseCommandLineArgument.ParseCommandLineArguments ( argv, utilityWhoIsArgument ); if (booleanParseCommandLineArguments == false) { // error encountered in arguments. Display usage message System.Console.Write ( UtilityParseCommandLineArgument.CommandLineArgumentsUsage(typeof(UtilityWhoIsPort43Argument)) ); return; }//if ( booleanParseCommandLineArguments == false ) WhoisLookup ( ref utilityWhoIsArgument, ref sb, ref exceptionMessage ); }//public static void Main()
}//public void ButtonReset_Click() /// <summary>WhoIsLookup</summary> public void WhoIsLookup() { string exceptionMessage = null; string[] registry = null; StringBuilder[][] sbWhoIs = null; StringBuilder sbJoin = null; UtilityWhoIsPort43Argument utilityWhoIsPort43Argument = null; try { UtilityWebControl.SelectedItem(ListBoxRegistry, ref registry); utilityWhoIsPort43Argument = new UtilityWhoIsPort43Argument ( RegistryDomainSuffixOnly, PortWhoIs, new string[] { DomainName }, registry ); UtilityWhoIsPort43.WhoisLookup ( ref utilityWhoIsPort43Argument, ref sbWhoIs, ref exceptionMessage ); if (exceptionMessage != null) { Feedback = exceptionMessage; return; } sbJoin = new StringBuilder(); for (int indexDimension1 = 0; indexDimension1 < sbWhoIs.Length; ++indexDimension1) { for (int indexDimension2 = 0; indexDimension2 < sbWhoIs[indexDimension1].Length; ++indexDimension2) { sbJoin.Append(sbWhoIs[indexDimension1][indexDimension2]); } //for ( int indexDimension2 = 0; indexDimension2 < sb[indexDimension1].Length; ++indexDimension2 ) } //for ( int indexDimension1 = 0; indexDimension1 < sb.Length; ++indexDimension1 ) } //try catch (Exception exception) { exceptionMessage = exception.Message; } if (exceptionMessage != null) { Feedback = exceptionMessage; } Feedback = sbJoin.ToString(); }//public void WhoIsLookup
}//public static void Main() ///<summary>WhoisLookup</summary> public static void WhoisLookup ( ref UtilityWhoIsPort43Argument utilityWhoIsArgument, ref StringBuilder[][] sb, ref string exceptionMessage ) { byte[] domainNameByte = null; bool registryDomainSuffixOnly = false; int domainIndex = -1; int registryIndex = -1; string domainName = null; string domainNameNewLine = null; string[] domainNameSplit = null; string readLine = null; string[] registry = null; string registryCurrent = null; HttpContext httpContext = HttpContext.Current; Stream stream = null; StreamReader streamReader = null; TcpClient tcpClient = null; try { if (utilityWhoIsArgument.registry.Length > 0) { registry = utilityWhoIsArgument.registry; } else if (utilityWhoIsArgument.registryDomainSuffixOnly == false) { UtilityString.ArrayCopy(RegistryWhoIs, ref registry, RankRegistryWhoIsName, ref exceptionMessage); if (exceptionMessage != null) { return; } } else { registryDomainSuffixOnly = true; } sb = new StringBuilder[utilityWhoIsArgument.domainName.Length][]; for (domainIndex = 0; domainIndex < utilityWhoIsArgument.domainName.Length; ++domainIndex) { domainName = utilityWhoIsArgument.domainName[domainIndex]; domainNameNewLine = domainName + Environment.NewLine; domainNameByte = Encoding.ASCII.GetBytes(domainNameNewLine.ToCharArray()); if (registryDomainSuffixOnly) { domainNameSplit = domainName.Split('.'); registry = new string[1]; registry[0] = RegistryWhoIs[0][RankRegistryWhoIsName]; for (int index = 0; index < RegistryWhoIs.Length; ++index) { if (RegistryWhoIs[index][RankRegistryWhoIsName].EndsWith(domainNameSplit[domainNameSplit.Length - 1].ToLower())) { registry[0] = RegistryWhoIs[index][RankRegistryWhoIsName]; break; } //if ( RegistryWhoIs[index][RankRegistryWhoIsName].EndsWith( domainNameSplit[domainNameSplit.Length-1].ToLower() ); } //for ( int index = 0; index < RegistryWhoIs.Length; ++index ) } //if ( registryDomainSuffixOnly == true ) sb[domainIndex] = new StringBuilder[registry.Length]; for (registryIndex = 0; registryIndex < registry.Length; ++registryIndex) { registryCurrent = registry[registryIndex]; tcpClient = new TcpClient(registryCurrent, utilityWhoIsArgument.port); stream = tcpClient.GetStream(); stream.Write(domainNameByte, 0, domainNameNewLine.Length); streamReader = new StreamReader(tcpClient.GetStream(), Encoding.ASCII); sb[domainIndex][registryIndex] = new StringBuilder(registryCurrent); if (httpContext == null) { sb[domainIndex][registryIndex].Append(Environment.NewLine); } else { sb[domainIndex][registryIndex].Append("<br/>"); } while (true) { readLine = streamReader.ReadLine(); if (readLine == null) { break; } if (httpContext == null) { System.Console.WriteLine(readLine); } sb[domainIndex][registryIndex].Append(readLine); if (httpContext != null) { sb[domainIndex][registryIndex].Append("<br/>"); } } //while ( true ) tcpClient.Close(); } //for ( registryIndex = 0; registryIndex < registry.Length; ++registryIndex ) } //foreach ( string domainName in utilityWhoIsArgument.domainName ) } //try catch (SocketException exception) { UtilityException.ExceptionLog(exception, exception.GetType().Name, ref exceptionMessage); } catch (Exception exception) { UtilityException.ExceptionLog(exception, exception.GetType().Name, ref exceptionMessage); } finally { if (tcpClient != null) { tcpClient.Close(); } } //finally } //WhoisLookup