开发者

C# TCP Client for WM6

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开发者_JAVA技巧 (Smart Device/NETCF3.5)? Any suggestion?

Thanks in advance!


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!


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜