03-21-2013 03:45 AM
03-21-2013 09:25 AM - edited 03-21-2013 09:29 AM
In Qt there's QTcpSocket & QTcpServer classes. Server application listens on some arbitrary port and client application connects to it.
TCP requires establishing a connection first. It guarantees reliable delivery of data.
Also there's QUDPSocket for connectionless sending of messages. When using UDP you can send packets of up to 64 kb in size, but the delivery order and the delivery itself is not guaranteed.
TCP server example:
TCP client example:
Basically any Qt examples will work, google "QTcpSocket example" for more examples.
If you don't want to allow apps from outside network to connect to your app, bind the server socket to a local interface (127.0.0.1).
It's also possible to broadcast the message to the entire network or send a multicast message to a group of recipients. Check broadcastsender & broadcastreceiver projects for an example of broadcast:
For communicating between two local apps I'd probably pick TCP or UDP.
Also Invocation Framework might be better for some tasks as it can launch the target application if it's not running.