Gethostentry Error By Gethostbyname Works
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies
Dns.gethostentry No Such Host Is Known
of this site About Us Learn more about Stack Overflow the company dns.gethostentry example Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges
Dns.gethostentry Fails On Ip Address
Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: dns.gethostentry ipv4 Sign up Dns.GetHostEntry error conditions and resolution methods up vote 7 down vote favorite 1 I have a very specific problem concerning Dns.GetHostEntry: A service uses Dns.GetHostEntry to retrieve all IP Adresses of a host, using the name of of the host. This has always worked fine. At a specific customer, Dns.GetHostEntry throws the "no such host is known" error when querying iphostentry specific hosts. The problem only occurs when trying to resolve hosts that are on a different domain than the machine the service is installed on. The service has worked for quite some time, but recently is stopped working, throwing the "no such host is known" error (sadly, no stack trace is available). Nslookup works though, no problems there. The service in question is written in VB.NET, targetting the .NET Framwork 2.0. The comments in the MSDN entry for .NET 3.0 (http://msdn.microsoft.com/en-us/library/ms143998(v=VS.85).aspx indictate that there may be a problem with the reverse DNS entries for the hosts, but I was not able to reproduce the problem on a test network, even with all reverse lookup zones deleted (there are more comments for other .NET Versions, all having similiar problems). [EDIT:] Even deliberatly addind a wrong PTR record does not make the problem occur on my test machine. [EDIT2:] The only thing that made the error come up was disconnecting the network adapter, and thereby making the DNS Server unavailable, even though the forward resolving still worked due to caching. So, my questions are: Under which cond
SQL Server 2014 Express resources Windows Server 2012 resources Programs MSDN subscriptions Overview Benefits Administrators Students Microsoft Imagine Microsoft Student Partners ISV Startups TechRewards Events Community Magazine Forums Blogs Channel 9 Documentation APIs and
System.net.dns Gethostentry Powershell
reference Dev centers Retired content Samples We’re sorry. The content you requested has c# get ip from hostname been removed. You’ll be auto redirected in 1 second. Ask a question Quick access Forums home Browse forums
System.net.sockets.socketexception No Such Host Is Known C#
users FAQ Search related threads Remove From My Forums Answered by: Dns.GetHostEntry raise "No such host is known"? Archived Forums N-R > Network Class Library (System.Net) Question 0 Sign in to http://stackoverflow.com/questions/4896180/dns-gethostentry-error-conditions-and-resolution-methods vote I think that most people know that"Dns.GetHostEntry(LocalIPAddress)" will raise a SocketException with "No such host is known"."LocalIPAddress" is the real IP address of the local machine which calls the function no matter IPv4 or IPv6 (but not the loopback 127.0.0.1 or the local machine name).I can find many reports of the problem in Web. Is it a design or bug? I find https://social.msdn.microsoft.com/Forums/en-US/3ac2b4eb-a50d-40f4-bcb7-af7b94467de0/dnsgethostentry-raise-no-such-host-is-known?forum=ncl the problem in both Dotnet2,3,3.5.The same problem does not happen when calls "Dns.GetHostByName(LocalIPAddress)". Wednesday, November 12, 2008 2:01 AM Answers 0 Sign in to vote I read your post numerous times and I think I know what is going on. In your first case it will return a short name and thats why it will invoke function A. In the second case you get a fully quallified domain name, that's why you get function B. They are different code paths.Mariya Proposed as answer by Mariya Atanasova [Microsoft Edge]Moderator Friday, February 06, 2009 1:47 AM Marked as answer by Mariya Atanasova [Microsoft Edge]Moderator Friday, February 13, 2009 8:58 PM Friday, February 06, 2009 1:47 AM Moderator All replies 0 Sign in to vote seems to work for me Dim IPhe As IPHostEntry Try IPhe = System.Net.Dns.GetHostEntry("") 'lookup my address Debug.WriteLine(IPhe.HostName) Debug.WriteLine(IPhe.AddressList(0).ToString) Catch ex As Exception Debug.WriteLine(ex.Message) Stop End Try Edited by dbasnett Wednesday, November 12, 2008 2:57 PM Wednesday, November 12, 2008 2:53 PM 0 Sign in to vote The question is not how to get local IP address. The local IP address has been known.The issue is that in a app, a field to be used to fill in the machine name/IPAddress. User can input any
send some data over a socket connection. The user can specify the destination by name or by http://www.rajapet.com/2011/11/replacing-gethostbyname-with.html IP address. I was using syntax like the following to http://www.codeproject.com/Questions/394325/DNS-not-working-on-online-server get the address IPAddress addr = Dns.GetHostByName(host).AddressList[0];IPEndPoint endPoint = new IPEndPoint(addr, 9100); That worked, but VS2010 spits out the following warning: ‘System.Net.Dns.GetHostByName(string)' is obsolete: ‘"GetHostByName is obsoleted for this type, please use GetHostEntry instead. http://go.microsoft.com/fwlink/?linkid=14202″‘ So I replaced the call to no such GetHostByName with GetHostEntry. When I passed in the IP address as a string GetHostByName, it threw an error, "No such host is known". That's not good. I didn't want to use obsolete code, but the recommended replacement wasn't working. I did a bit of searchnng on the Internets and found that GetHostEntry no such host attempts to do a DNS reverse resolve and that doesn't always work. As it turns out, GetHostEntry is not the only method that can be substituted for GetHostByName. GetHostAddresses will return the IP address for the specified host. I was able to use the following code without any warnings: IPAddress addr = Dns.GetHostAddresses(host)[0];IPEndPoint endPoint = new IPEndPoint(addr, 9100); And we are good. Share this:Click to email this to a friend (Opens in new window)Click to share on Facebook (Opens in new window)Click to share on LinkedIn (Opens in new window)Click to share on Reddit (Opens in new window)Click to share on Twitter (Opens in new window)Click to share on Google+ (Opens in new window)Click to print (Opens in new window)Like this:Like Loading... Related Post navigation Previous PostAn odd way to postNext PostAn open letter to Newport Television 2 thoughts on “Replacing GetHostByName with GetHostAddresses” zooplah says: March 6, 2012 at 10:53
Tips/Tricks Top Articles Beginner Articles Technical Blogs Posting/Update Guidelines Article Help Forum Article Competition Submit an article or tip Post your Blog quick answersQ&A Ask a Question View Unanswered Questions View All Questions... C# questions Linux questions ASP.NET questions SQL questions VB.NET questions discussionsforums All Message Boards... Application Lifecycle> Running a Business Sales / Marketing Collaboration / Beta Testing Work Issues Design and Architecture ASP.NET JavaScript C / C++ / MFC> ATL / WTL / STL Managed C++/CLI C# Free Tools Objective-C and Swift Database Hardware & Devices> System Admin Hosting and Servers Java .NET Framework Android iOS Mobile SharePoint Silverlight / WPF Visual Basic Web Development Site Bugs / Suggestions Spam and Abuse Watch features Competitions News The Insider Newsletter The Daily Build Newsletter Newsletter archive Surveys Product Showcase Research Library CodeProject Stuff communitylounge Who's Who Most Valuable Professionals The Lounge The Insider News The Weird & The Wonderful The Soapbox Press Releases Non-English Language > General Indian Topics General Chinese Topics help What is 'CodeProject'? General FAQ Ask a Question Bugs and Suggestions Article Help Forum Site Map Advertise with us About our Advertising Employment Opportunities About Us Ask a Question All Questions All Unanswered FAQ DNS not working on online server Rate this: Please Sign up or sign in to vote. See more: ASP.NET Hi, I want client machine name where the ASP.Net web application is running. I am using below code: var hostEntry = Dns.GetHostEntry(Request.UserHostAddress); Response.Write("machinename=" + hostEntry.HostName); Its working Offline but not working on online server. It shows this error: Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Net.Sockets.SocketException: No such host is known Source Error: An unhandled exc