EQL5/examples/9-simple-lisp-editor/send/send.cpp
2016-11-25 23:30:38 +01:00

31 lines
1.1 KiB
C++

#include <QtCore>
#include <QtNetwork>
#include <QtDebug>
#include <iostream>
int main(int argc, char** argv) {
QCoreApplication qapp(argc, argv);
QLocalSocket socket;
socket.connectToServer("EQL:local-server");
socket.waitForConnected();
qapp.processEvents();
QString exp(QCoreApplication::arguments().at(1));
if(socket.isWritable()) {
QString data(QString::number(exp.size()) + " " + exp);
socket.write(data.toLatin1());
qapp.processEvents();
socket.waitForBytesWritten();
while(true) {
socket.waitForReadyRead();
qapp.processEvents();
QString data(socket.readAll());
QString type(data.section(' ', 1, 1));
if(!(":EXPRESSION" == type)) {
QString print(data.section(' ', 2).trimmed());
if(!print.isEmpty()) {
std::cout << qPrintable(print) << std::endl; }
if(":VALUES" == type) {
exit(0); }}}}
qCritical() << "[send] error:" << exp;
return -1; }