views:

282

answers:

3

I'm the author of an Open Source kiosk management system, Libki. The current version, though functional, was very much a learning experience for me. I'm working on a complete rewrite and am having a hard time deciding what protocol to use.

The server will be written in PHP or Perl. Most likely PHP because I need to support some uncommon protocols that Library software use, ( SIP and NCIP ). So far I've only found a SIP2 library in PHP.

The client is written in C++/Qt4.

I'm looking at RPC and REST for client/server communication. I've found RPC client libraries for Qt4, and REST is already part of the Qt4 libraries.

Is there an alternative I've missed? So far, REST seems to be the winner.

A: 

Don't know if best, but for a proof of concept I had to do, I used a TCP socket on the Qt4 server, and the Mono/C# client would connect 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 that on_data_read() I will probably get XML instead just a file name, since I need to get also commands. Other alternatives are shared memory, a unix socket (similar to this code), and if you want to go hight: XMLRPC or SOAP, or even dbus.

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

elcuco
A: 

One alternative you didn't mention is SOAP, though for this application I think REST is still the best solution.

Narthring
+2  A: 

There's Google's protobuf, and you can find bindings for PHP here.

Gianni