Networks with no DNS

J

Joe Bain

I have written a .net program that runs on a pocketPC that talks
wirelessly to a non .net program on a sever though sockets. The program
works fine on our network here, but on the customers it gets an
exception "No such host is known". I do not think their network has a
DNS server. Here is code I use to connect. The string ServerAddr is the
IP address of the server in string form.

socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp);
socket.Blocking = true;
IPHostEntry IPHost = Dns.GetHostByAddress(IPAddress.Parse(ServerAddr));

string[] aliases = IPHost.Aliases;
IPAddress[] addr = IPHost.AddressList;
IPEndPoint ipepServer = new IPEndPoint(addr[0], Port);
socket.Connect(ipepServer);

If it would help I could give you the results of IPConfig when run from
the command line on the server. I can also ping the server from the
PocketPC so I know that it can see the server.
 
P

Paul G. Tobey [eMVP]

Why not just use the IP address of the destination of that connection,
rather than translating it backward to a host name and then resolving the
name again? That is:

socket.Connect( new IPEndPoint( IPAddress.Parse("1.2.3.4"), portnumber ) );

Paul T.
 

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

Top