Groups | Blog | Home
all groups > dotnet compact framework > september 2007 >

dotnet compact framework : TcpClient Problem


Paul G. Tobey [eMVP]
9/27/2007 9:23:49 AM
It sounds like there is no network path from you, on the device, to the PC.
That's probably not a feature of what sort of an adapter is used, but
whether it's actually connected to the right access point/wireless network.
You should compare the wireless configurations on the two devices...

Paul T.

[quoted text, click to view]

Simon Hart
9/27/2007 1:00:01 PM
In addition to Paul's comments. Have you tried using the Socket class?
TcpClient can be problematic at times and is not really designed for
enterprise apps. I would stay away from TcpClient.
--
Simon Hart
http://simonrhart.blogspot.com


[quoted text, click to view]
Andy Baker
9/27/2007 1:45:10 PM
I have a VB.NET 2003 application that has been running successfully on a
device running CE.NET 4.2. I have recently been supplied with the latest
version of the device, which runs CE.NET 5, and also has a different WiFi
adapter to my original version. The application connects to a desktop PC
using a TcpClient as follows:-

Private client as TcpClient
client = New TcpClient(IPAddress, PORT_NUM)

where IPAddress is 192.169.1.10 (the address of the host PC) and PORT_NUM is
a constant - the number of the port I want to use for the connection (10000
in this case). The application on the host PC has a listener object waiting
for a connection on the same port number. On the CE 4.2 device it works
fine, on the new one I get the error message 'No such host is known' after a
few seconds (on the New TcpClient line above). Is this likely to be a CE
problem or a WiFi adapter problem (or something else), and what can I do
about it? Thanks in advance.

Andy Baker

Andy Baker
9/28/2007 12:00:00 AM
It seems to be more complicated than that. I should have said that I can
ping the host PC from the device successfully using the same IP address as I
am using in the TcpClient I have checked the wireless configuration settings
and they seem to be identical. Under the 'Wireless Information' tab it
reports it as being connected and IP information / subnet mask is correct.
Are there any more settings that I am not aware of?

Andy Baker

"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
[quoted text, click to view]

Andy Baker
9/28/2007 12:00:00 AM
I will look at that in the future. Unfortunately time is pressing at the
moment and it worked before so I would prefer not to have to change at
present. Thanks for the suggestion.

Andy Baker

[quoted text, click to view]

Paul G. Tobey [eMVP]
9/28/2007 8:08:02 AM
No. Connectivity is all you need. Maybe you specified the wrong port
number or something. As Simon said, try plain sockets, if that doesn't seem
to be the problem...

Paul T.

[quoted text, click to view]

Paul G. Tobey [eMVP]
10/15/2007 8:09:39 AM
When you pass a string, that's interpreted as a host name, *NOT* an IP
address.

Paul T.

[quoted text, click to view]

Paul G. Tobey [eMVP]
10/15/2007 8:58:36 AM
I've never been able to get any of my devices to interpret a string
parameter as a host name. It's possible, I guess, that some setting, a
hosts 'file' setting or something (something that I wouldn't have), allows
that entry to be interpreted that way. I think it would have to be
something that was essentially disconnected from your actual code. In any
case, take care with that parameter...

Paul T.

[quoted text, click to view]

Paul G. Tobey [eMVP]
10/15/2007 9:03:20 AM
Let me try that again. I've not been able to get them to interpret a string
as an *IP address*...

Paul T.

"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
[quoted text, click to view]

Andy Baker
10/15/2007 3:55:19 PM
I have got it working. I have changed the code to create the TcpClient
first, then connect using an IPAddress rather than a string i.e.
Dim ParsedIPAddress as IPAddress
ParsedIPAddress = IPAddress.Parse("192.168.1.10")
client = New TcpClient
client.Connect(ParsedIPAddress, PORT_NUM)
and it works as it did before on the previous WiFi card/CE combination. I
don't know why it should work with one and not the other, but at least it
gets me out of trouble. Thanks for your help.

"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
[quoted text, click to view]

Andy Baker
10/15/2007 4:48:57 PM
OK, but why did the other device work - it obviously managed to interpret
the string as an IP address!

Andy

"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
[quoted text, click to view]

Andy Baker
10/16/2007 12:00:00 AM
I'll remember that in future. The problem was that I didn't write the code,
and didn't really look into how it worked. It always worked on the previous
device, and when we got a new device with a different radio card and
different version of CE.NET, I assumed that it had to be one or the other
that was causing the problem. It seems like the question now is why did it
work on the previous device, but I won't worry about that too much!

Andy Baker

"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
[quoted text, click to view]

AddThis Social Bookmark Button