CF.Net TCP client

  • Thread starter Thread starter Adam Goetz
  • Start date Start date
A

Adam Goetz

I hope that this is just a really easy question.

Why does this command work on the emulator, but causes a 'host not found'
exception on a device, when the device can ping the ip address listed and
the server program is running? Connection i via 802.11b network.

TcpClient client = new TcpClient("192.168.0.100", 11000);
 
You need to read the description of the actual constructor form that you are
calling there. As you can see, the (string, int) constructor expects the
host *name* as the string, not an IP address. In fact, it's trying to
resolve the 'name' that you've passed as though it was www.microsoft.com or
something via DNS, which it can't do. Obviously, there's a little
incompatibility there between the CF and the desktop, where the emulator is
running. The CF implementation is actually right, based on the method
description in the help.

For specifying an IP address, try the default constructor and use one of the
Connect method calls to specify the target system.

Paul T.
 
For example you could try
new TcpClient(new IPEndpoint(IPAddress.Parse("192.168.0.100"), 11000);
 
Back
Top