Dns, IP & WebRequest ?

  • Thread starter Thread starter Lloyd Dupont
  • Start date Start date
L

Lloyd Dupont

On pocket pc I am able to access remote computer through their IP or name
with a WebRequest with something like
WebRequest.Create("http://"+myhostIP+"/blablabla);

however when I try to get an IP endpoint to myhostIP with
Dns.GetHostByAddress(myhostIP);

I get a socket exception : temprorary error during hostname resolution ....

mmhh..
what could I do ?
 
That request, GetHostByAddress() is going to attempt to do a reverse DNS
lookup, RDNS, of the IP address. Are you sure that the DNS server
configured for the device where you are running this code *has* any DNS
entry at all for the specified machine? It would be somewhat unusual to
have a local machine on an internal network which can be looked up via DNS.

If you just want to connect to the machine via its IP addres, you don't have
to do anything with DNS. You can do something like this:

new System.Net.IPEndPoint(

IPAddress.Parse( ipAddressEdit.Text ),

Int32.Parse( tcpPortEdit.Text ) );

In this sample, tcpPortEdit and ipAddressEdit are text edit fields on the
form, so I'm just parsing their values and using them as the IP address and
TCP port number for an IPEndPoint.

Paul T.
 
If you just want to connect to the machine via its IP addres, you don't
have
to do anything with DNS. You can do something like this:

new System.Net.IPEndPoint(

IPAddress.Parse( ipAddressEdit.Text ),

Int32.Parse( tcpPortEdit.Text ) );
thanks ! many thanks !
it was exactly what I was trying to do !
and I'm kind of newby with these networking classes...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top