不知道是否最好,但爲了證明我不得不做的,我在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。