不知道是否最好,但为了证明我不得不做的,我在Qt4服务器上使用了一个TCP套接字,并且Mono/C#客户端将连接到它。这里是我的代码草图:
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));
}
注意on_data_read()
我可能会得到XML,而不只是一个文件名,因为我需要还命令。其他选择是共享内存,unix套接字(与此代码类似),以及如果您想要继续:XMLRPC或SOAP,甚至dbus。
查看qt/examples/network /,qt/examples/dbus,qt/examples/ipc。