CF.Net TCP client

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

Paul G. Tobey [eMVP]

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.
 
A

Alex Feinman [MVP]

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

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