No DNS server

J

Joe Bain

Sorry if this is a repost, I don't think the first on sent.

I have made a program that runs on a .net PocketPC that talks over a
wireless network with a server running a program that is not written in
..net. The program works fine here, but gives an error message of "No
such host is known" at the customers location. I do not think they have
a DNS server at their place. In csharp how do you connect with TCP to a
server without causing a DNS lookup. Here is the code I am using now.
Not that ServerAddr is a string containing the valid IPAddress of the
server.

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);


I can give you the output of IPConfig run from the server if it will
help. Also I can ping the server from the pocketPC so I know it can see
it.
 
L

Lloyd Dupont

I don't understand your question,
what's wrong with
IPAddress ia = IPAddress.Parse(ipAddressString);
IPEndPoint iep = new IPEndPoint(ia, port);

??

and it does work on PPC !
 
W

William Stacey [MVP]

Don't do the GetHostByAddress step. Just use a fixed IP like
IPAddress.Parse("1.1.1.1") and give that IP to your EndPoint.
 

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