The best protocol for client / server interaction, from PHP / Perl to C ++ / Qt4

I am the author of the open source kiosk management system, Libki. The current version, although functional, was a very educational experience for me. I'm working on a complete rewrite, and it's hard for me to decide which protocol to use.

The server will be written in PHP or Perl. Most likely, PHP, because I need to support some unusual protocols that the library software uses ( SIP and NCIP ). So far, I have only found the SIP2 library in PHP.

The client is written in C ++ / Qt4.

I am looking at RPC and REST for client / server interactions. I found the RPC client libraries for Qt4, and REST is already part of the Qt4 libraries.

Is there an alternative I missed? So far, REST seems to be winning.

+3
source share
3 answers

There Google protobuf and you can find the bindings for PHP here .

+2
source

I don’t know if it’s better, but to prove the concept that I had to do, I used the TCP socket on the Qt4 server and the Mono / C # client connected to it. Here is a sketch of my code:

MainWindow::mainWindow()
{
    // more non relevant crap
    tcpServer = new QTcpServer(this);
    tcpServer->listen(QHostAddress::Any,3333);
    connect(tcpServer,SIGNAL(newConnection()),this,SLOT(on_new_serverConnection()));
}

void MainWindow::on_new_serverConnection()
{
    connection = tcpServer->nextPendingConnection();
    connect(connection, SIGNAL(readyRead()), this, SLOT(on_data_read()));
}

void MainWindow::on_data_read()
{
    QString s = connection->readAll();
    qDebug("file to load - %s", qPrintable(s));
}

Note: on_data_read()I will most likely get XML instead of the file name, since I need to get the commands as well. Other alternatives are shared memory, a unix socket (similar to this code), and if you want to go in: XMLRPC or SOAP or even dbus.

qt/examples/network/, qt/examples/dbus, qt/examples/ipc.

0

One alternative that you did not mention is SOAP, although for this application I believe that REST is still the best solution.

0
source

Source: https://habr.com/ru/post/1743976/


All Articles