locked
TCP Client for Windows Mobile 6.1 PDA RRS feed

  • Question

  • Hi,

    I am developing a TCP client application for PDA powered by Windows Mobile 6.1, I am using VS 2008 with TCPClient class of System.Net.Sockets namespace to send a string to a TCP server windows application located on the same machine (host: localhost, port:13000) but when I try to connect the client I had this exception:

    {"No connection could be made because the target machine actively refused it"}

    Here is my TCP Client code to send data to the server

     

    try
       {
        // Create a TcpClient.
        // Note, for this client to work you need to have a TcpServer 
        // connected to the same address as specified by the server, port
        // combination.
        Int32 port = 13000;
        TcpClient client = new TcpClient(server, port);
    
        // Translate the passed message into ASCII and store it as a Byte array.
        Byte[] data = System.Text.Encoding.ASCII.GetBytes(message);
    
        // Get a client stream for reading and writing.
        // Stream stream = client.GetStream();
    
        NetworkStream stream = client.GetStream();
    
        // Send the message to the connected TcpServer. 
        stream.Write(data, 0, data.Length);
    
    
        // Close everything.
        client.Close();
       }
       catch (ArgumentNullException e)
       {
        MessageBox.Show("ArgumentNullException: "+ e);
       }
       catch (SocketException e)
       {
        MessageBox.Show("SocketException: {0}"+ e);
       }
    


    I am developing it on windows mobile 6.0 professional emulator on Windows 7.0 machine.

    Notes:

    - I already disabled windows firewall and still don't work.

    I need your help please.

    Sunday, June 12, 2011 1:01 PM

Answers

  • Please see this: http://social.msdn.microsoft.com/forums/en-us/windowsmobiledev/thread/E988A111-33A2-41D4-A05F-27B5CFDA15AF

     


    This posting is provided "AS IS" with no warranties, and confers no rights.
    • Proposed as answer by Jesse Jiang Wednesday, June 15, 2011 8:40 AM
    • Marked as answer by Jesse Jiang Tuesday, June 28, 2011 8:25 AM
    Sunday, June 12, 2011 4:02 PM
  • Thanks for your Help, yeah I solved the issue by connecting to a remote server not on the local machine, but what about setting the SendTimeOut and ReceiveTimeOut properties of the TCPClient class it raises an exception when I tried to set them before connecting to the server.
    • Proposed as answer by Jesse Jiang Wednesday, June 15, 2011 8:40 AM
    • Marked as answer by Jesse Jiang Tuesday, June 28, 2011 8:25 AM
    Monday, June 13, 2011 11:18 AM

All replies

  • Please see this: http://social.msdn.microsoft.com/forums/en-us/windowsmobiledev/thread/E988A111-33A2-41D4-A05F-27B5CFDA15AF

     


    This posting is provided "AS IS" with no warranties, and confers no rights.
    • Proposed as answer by Jesse Jiang Wednesday, June 15, 2011 8:40 AM
    • Marked as answer by Jesse Jiang Tuesday, June 28, 2011 8:25 AM
    Sunday, June 12, 2011 4:02 PM
  • Thanks for your Help, yeah I solved the issue by connecting to a remote server not on the local machine, but what about setting the SendTimeOut and ReceiveTimeOut properties of the TCPClient class it raises an exception when I tried to set them before connecting to the server.
    • Proposed as answer by Jesse Jiang Wednesday, June 15, 2011 8:40 AM
    • Marked as answer by Jesse Jiang Tuesday, June 28, 2011 8:25 AM
    Monday, June 13, 2011 11:18 AM
  • If you solved your problem then mark thread as answered. If you have other questions please create new thread with appropriate title and description including source code, detailed exception description, etc.
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Monday, June 13, 2011 4:12 PM