PDA

View Full Version : Sending commands throught network



franco.amato
26th March 2012, 18:47
Good morning, I would write an application ( or better add a feature to an existing application ) where an application sends some simple custom commands ( like "OPEN_DOOR" ) to another application. Both applications resides in different pcs.
How can I do? I saw the QNetwork module but I'm not sure what I would is a client-server application as is just some custom string sending.
For example pc1 send "OPEN_DOOR" to pc2 and this one execute a local slot.

Best Regards,
Franco

ChrisW67
26th March 2012, 22:33
There's no magic connection between signals in one process and slots in another.

Your requirement to send a command from A to B makes A the client (sender) and B the server (receiver). Your sender needs to send the command and await the response (if any). Your receiver needs to listen for command(s), determine what command has been received, do something, and return a result. Depending on reliability requirements you could use QTcpSocket and QTcpServer, or QUdpSocket, if everything will be on the same machine then you could look at QLocalSocket/QLocalServer. See Inter-Process Communication in Qt