locked
Unable to Send Data on UDP in Windows Mobile..?? RRS feed

  • Question

  • Hello friends.....
    I have written the following Code snippet to send Data on Server on UDP port....
    i am not getting any exception....it prints "Send Successfully" msg.... But i am not getting any data on server....
    am i doing something wrong....?
    I am using VS08, WM 6.0 SDT SDK, C#, 3.5 CF... and running app on Device..HTC S170

    private static void Send( String message)
                {
                    IPAddress GroupAddress =
                    IPAddress.Parse("*.*.*.*");
                    int GroupPort = 7299;
       
                    UdpClient sender = new UdpClient();
                    IPEndPoint groupEP = new IPEndPoint(GroupAddress,GroupPort);

                    try {
                    byte[] bytes = Encoding.ASCII.GetBytes(message);

                    sender.Send(bytes, bytes.Length, groupEP);
                   
                    sender.Close();

                    MessageBox.Show("Send Successfully");
                   
                    } catch (Exception e)
                    {
                         MessageBox.Show(e.ToString());
                    }       
                }

    Please reply..
    Thanks Pranay@MobileDev http://pranayurkude.blogspot.com/
    Wednesday, July 8, 2009 5:34 AM

Answers

  • What's the sever side code? A possible reason is that the device cannot connect to the server. You can use the ping tool to test the connection:
    Windows Mobile Network Analyzer PowerToy 
     
    I would also suggest that you first make a server/client on desktop PC. The following article shows you an example:
    http://www.codeproject.com/KB/IP/TinyUDP.aspx 

    Once you can make it work on PC, try to migrate the cilent code to Windows Mobile.


    Please mark the post that helps you, and unmark that does not. This benefits our community members.
    • Marked as answer by warrentang Tuesday, July 14, 2009 2:34 AM
    Friday, July 10, 2009 8:14 AM

All replies

  • Hi Pranay ,

    Please refer ,
    http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/647fd90c-1270-422c-a45b-f1c7a16c42d7


    or
    Crosscheck this :

                    UdpClient udpClient = new UdpClient();
                    Byte[] inputToBeSent = new Byte[256];

                    inputToBeSent = Encoding.ASCII.GetBytes(message);

                    udpClient.Connect(IPAddress.Parse("127.0.0.1"), 11001);

                    int nBytesSent = udpClient.Send(inputToBeSent, inputToBeSent.Length);

                    udpClient.Close();




    Thanks Mohsin S.
    Wednesday, July 8, 2009 5:49 AM
  • Thanks Mohsin... for reply...
    unable to get success...

    when i used same code snippet for desktop app.. it works fine.. it send data to the server....
    But when trying to send from device..it does not give any exception...but the data is not reached to the server....

    any idea why it is so happening..


    Thanks Pranay@MobileDev http://pranayurkude.blogspot.com/
    Wednesday, July 8, 2009 6:49 AM
  • Hi,

    The following is also useful to know :-

    http://blogs.msdn.com/anthonywong/archive/2006/03/13/550686.aspx

    Hope this helps.

    Paul Diston
    http://www.smartmobiledevice.co.uk/
    Wednesday, July 8, 2009 7:17 AM
  • thanks sir..
    i hv already follow this link, but nt get any success....
     

    Thanks Pranay@MobileDev http://pranayurkude.blogspot.com/
    Wednesday, July 8, 2009 7:20 AM
  • What's the sever side code? A possible reason is that the device cannot connect to the server. You can use the ping tool to test the connection:
    Windows Mobile Network Analyzer PowerToy 
     
    I would also suggest that you first make a server/client on desktop PC. The following article shows you an example:
    http://www.codeproject.com/KB/IP/TinyUDP.aspx 

    Once you can make it work on PC, try to migrate the cilent code to Windows Mobile.


    Please mark the post that helps you, and unmark that does not. This benefits our community members.
    • Marked as answer by warrentang Tuesday, July 14, 2009 2:34 AM
    Friday, July 10, 2009 8:14 AM