Results 1 to 2 of 2

Thread: UDP on the same machine??

  1. #1
    Join Date
    Feb 2011
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default UDP on the same machine??

    Is it possible to UDP between two separate applications on the same PC?

    I have a need to test an application that I wrote that is meant to communicate via unicast UDP to a special device. I don't have regular access to this device, so I would like to write a "simulator" that would run on the same computer. My application would talk UDP to that simulator, which in turn would provide responses.

    Is this possible?

    In fact, I have tried using the code snippets shown below with no success. I don't see any data being sent or received. I'm wondering if I don't have the IP/ports set correctly.

    I would very much appreciate any assistance or advice.

    Bryan

    Qt Code:
    1. Application A (my application):
    2. IP_mine = QHostAddress("Localhost");
    3. IP_target = QHostAddress("Localhost");
    4. port_mine = 51200;
    5. port_target = 51201;
    6. bool success = m_udpSocket.bind(IP_mine,port_mine);
    7. .
    8. .
    9. .
    10. m_udpSocket.writeDatagram((char*)&buffer,sizeof(buffer), IP_target, port_send);
    11.  
    12.  
    13.  
    14. Application B (my simulator):
    15. IP_mine = QHostAddress("Localhost");
    16. IP_target = QHostAddress("Localhost");
    17. port_mine = 51201;
    18. port_target = 51200;
    19. bool success = m_udpSocket.bind(IP_mine,port_mine);
    20. .
    21. .
    22. .
    23. m_udpSocket.writeDatagram((char*)&buffer,sizeof(buffer), IP_target, port_send);
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Oct 2009
    Posts
    364
    Thanks
    10
    Thanked 37 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: UDP on the same machine??

    take a look at broadcast sender/receiver example, I think that is exactly what you need.

Similar Threads

  1. how to run Qt programs on non qt machine ?
    By aamer4yu in forum Installation and Deployment
    Replies: 15
    Last Post: 11th July 2012, 07:38
  2. Replies: 7
    Last Post: 19th April 2011, 12:20
  3. Replies: 2
    Last Post: 22nd December 2009, 20:52
  4. qtdemo 4.4 looks like this on my machine!
    By magland in forum General Discussion
    Replies: 1
    Last Post: 25th May 2008, 07:55
  5. Suggession to install both qt3.3.4 and qt4.2.2 in the same machine
    By joseph in forum Installation and Deployment
    Replies: 1
    Last Post: 20th June 2007, 07:05

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.