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