Click here to Skip to main content
15,888,062 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
C#
Hello ,

i have to try to connect one ip address in my desktop application with the 

dns.beginhostentry but it gives error "no such host is known" 

while i am using with alias its works fine for the same ip 

address. 

example :

string ip_address ="123.456.789.012" 
string alias = "mymachine" 'this is alias of above ip address.

DNS.BeginGetHostEntry(ip_address,abcd,this); this statement does 

not works. it show the error that "no such host is known".

while

DNS.BeginGetHostEntry(alias,abcd,this);

this statement does works no issues at all.



please solve this query.

thanks


What I have tried:

C#
Note : i dont want to do host entry into the host file of the any 

particular pc. because i want to fix the ip address at all. 
Posted
Updated 19-Dec-16 19:03pm

1 solution

If you read the documentation for BeginGetHostEntry, the IP address parameter is a System.Net.IPAddress, which is not the same as a string representation. Convert your numbers to an IPAddress and try again.
 
Share this answer
 
Comments
bhudev 20-Dec-16 1:22am    
i have do following changes but there is no luck for the same.

IPAddress address = IPAddress.Parse(ip_address);
DNS.BeginGetHostEntry(address,abcd,this);
Nnamani Uchenna 5-Feb-18 7:19am    
"123.456.789.012" is not a valid ip address no "456.789"

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900