views:

36

answers:

2

Hello,

Im trying to make a TCP client application for a PDA with Windows Mobile 6 Professional. I tried to make it first on my laptop and it worked. The code for the "smart device" is exaclty the same but it doesn't work.

Here it is the code:

// IP and Port
string IP = "192.168.1.68";
int port = 1000;

// TCP connection
TcpClient connection;
StreamReader TCPreader;
StreamWriter TCPwriter;

//(...)

    try
    {
        connection = new TcpClient(IP, port);
        NetworkStream stream = connection.GetStream();
        TCPreader = new StreamReader(stream);
        TCPwriter = new StreamWriter(stream);

        // wait for welcome message
        status_label.Text = TCPreader.ReadLine();
    }
    catch(Exception ex)
    {
        MessageBox.Show("ERROR: " + ex.Message);
    }

An exception is thrown on "readLine()" method call. I can't get the message, otherwise I get something like this "this exception message is not installed, you have to install NETCFv35.messages.en.cab". I already installed that .cab but I get the same message.

What is going wrong? Why this code works on my laptop (WinForms app/NET3.5) and doesn't on PDA (Smart Device/NETCF3.5)? Any suggestion?

Thanks in advance!

A: 

Check your firewall, and that your server is running.

I'm not sure why you can't see the error messages; try casting it to SocketException and extracting the ErrorCode.

Stephen Cleary
The firewall is disabled and I still get this error. Can't connect to TCP Server.
msr
A: 

I think I found the problem. While my PDA is connected through USB to my laptop, WiFi is disabled. Arghhh I just disconnect PDA from my laptop and now I cant send/receive messagens from 192.168.1.68.

Thanks all for your hints!

msr