X-Recipient: archive-cygwin AT delorie DOT com X-Original-To: cygwin AT cygwin DOT com Delivered-To: cygwin AT cygwin DOT com DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 78505385E000 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=dillinger.biz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Raimund DOT Paulus AT dillinger DOT biz From: "PAULUS, Raimund, TI-ABN" To: "'cygwin AT cygwin DOT com'" Subject: Problems using Qt5 and Apache Thrift Thread-Topic: Problems using Qt5 and Apache Thrift Thread-Index: AdYCgwCD6HT+yRQXSXGNf/3ZvHbang== Date: Wed, 25 Mar 2020 09:04:10 +0000 Message-ID: <87e18da8dcf6464e81c38a7848e3a5c7@resw122.resdom01.local> Accept-Language: en-US Content-Language: de-DE X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [172.18.22.70] MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.99.3 at mailrelay.dillinger.de X-Virus-Status: Clean X-Spam-Status: No, score=-5.3 required=5.0 tests=BAYES_00, GIT_PATCH_2, KAM_ASCII_DIVIDERS, KAM_DMARC_STATUS, KAM_INFOUSMEBIZ, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: cygwin AT cygwin DOT com X-Mailman-Version: 2.1.29 List-Id: General Cygwin discussions and problem reports List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "Cygwin" Problems using Qt5 and Apache Thrift For several months i use Apache Thrift 0.11.0 on Cygwin 2.5.2 for data transfer between Windows boxes and my Linux host. On the Windows boxes a C++-application serves as a client. The user makes some input on an ascii-interface (created with libwed) and sometimes data must be transferred between the pc and the Linux host. Here is the program sequence on the windows client: //------------------------------------------------------------------------------ program starts step 1: make the connection to the Linux server (Apache Thrift) step 2: user interface (ASCII) step 3: data transfer PC <-> Linux-Host (Apache Thrift) step 4: user interface (ASCII) step 5: data transfer PC <-> Linux-Host (Apache Thrift) ... ... ... step n: close the connection to the host (Apache Thrift) program ends //------------------------------------------------------------------------------ This works flawlessly. Now i want to implement the interface parts with Qt 5. Here is the new program sequence: //------------------------------------------------------------------------------ program starts step 1: make the connection to the Linux server (Apache Thrift) step 2: initialize Qt interface (create widgets, buttons, ...) step 3: user interface (Qt) step 4: data transfer PC <-> Linux-Host (Apache Thrift) step 5: user interface (Qt) step 6: data transfer PC <-> Linux-Host (Apache Thrift) ... ... ... step n-1: end Qt app step n: close the connection to the host (Apache Thrift) program ends //------------------------------------------------------------------------------ During step 2 the connection to the linux server is broken. You can see it with the netstat command. First error message arises in step 4: "TSocket::write_partial() send() Broken pipe" On a Linux box the client program runs perfectly. On the windows box the program works, if i initalize Qt before the connection to the server is made (step 2 before step 1). But that is not acceptable for me, because afterwards other widgets and buttons are created and i can not close and create the connection at each point. For the tests I used the examples from the Apache Thrift Tutorial. The service on the linux box is created from CppServer.cpp. The client in the original is CppClient.cpp. But I modified it for Qt. Here is the source for CppClient.cpp. The connection is broken after line 66. 1 #include 2 #include 3 4 #include 5 #include 6 #include 7 #include 8 #include 9 10 #include 11 #include 12 #include 13 #include 14 15 #include "../gen-cpp/Calculator.h" 16 17 using namespace std; 18 using namespace apache::thrift; 19 using namespace apache::thrift::protocol; 20 using namespace apache::thrift::transport; 21 22 using namespace tutorial; 23 using namespace shared; 24 25 // function for messagebox 26 void MsgBox(const char *msg) 27 { 28 QMessageBox box; 29 box.setIcon(QMessageBox::Information); 30 box.setText("Server Return"); 31 box.setInformativeText(QString::fromStdString(msg)); 32 box.setStandardButtons(QMessageBox::Ok); 33 box.exec(); 34 } 35 36 int main(int argc, char **argv) { 37 38 //------------------------------------------------------- 39 // connect to host before initialising Qt 40 //------------------------------------------------------- 41 printf("Connect to host \"NAZV\"with port 9090\n"); 42 43 // stdcxx::shared_ptr socket(new TSocket("localhost", 9090)); 44 stdcxx::shared_ptr socket(new TSocket("NAZV", 9090)); 45 stdcxx::shared_ptr transport(new TBufferedTransport(socket)); 46 stdcxx::shared_ptr protocol(new TBinaryProtocol(transport)); 47 CalculatorClient client(protocol); 48 49 try { 50 transport->open(); 51 52 //------------------------------------------------------ 53 // initialising Qt after connect to host 54 //------------------------------------------------------ 55 printf("Stop 1; Press to continue"); getchar(); 56 57 QApplication app(argc, argv); 58 QString txt; 59 60 printf("Stop 2; Press to continue"); getchar(); 61 62 QWidget *w = new QWidget(); 63 64 printf("Stop 3; Press to continue"); getchar(); 65 66 QPushButton *b_end = new QPushButton("End", w); 67 68 printf("Stop 4; Press to continue"); getchar(); 69 70 QObject::connect(b_end, SIGNAL(clicked()), &app, SLOT(quit())); 71 72 printf("Stop 5; Press to continue"); getchar(); 73 74 w->show(); 75 76 printf("Stop 6; Press to continue"); getchar(); 77 78 79 client.ping(); 80 MsgBox("ping()"); 81 82 txt.clear(); 83 txt.append("1 + 1 = "); 84 txt.append(QString::number(client.add(1, 1))); 85 MsgBox(txt.toStdString().c_str()); 86 87 Work work; 88 work.op = Operation::DIVIDE; 89 work.num1 = 1; 90 work.num2 = 0; 91 92 try { 93 client.calculate(1, work); 94 MsgBox("Whoa? We can divide by zero!"); 95 } catch (InvalidOperation& io) { 96 txt.clear(); 97 txt.append("InvalidOperation: "); 98 txt.append(io.why.c_str()); 99 MsgBox(txt.toStdString().c_str()); 100 } 101 102 work.op = Operation::SUBTRACT; 103 work.num1 = 15; 104 work.num2 = 10; 105 int32_t diff = client.calculate(1, work); 106 txt.clear(); 107 txt.append("15 - 10 = "); 108 txt.append(QString::number(diff)); 109 MsgBox(txt.toStdString().c_str()); 110 111 112 app.exec(); 113 114 transport->close(); 115 } catch (TException& tx) { 116 cout << "ERROR: " << tx.what(); 117 } 118 119 } The result is the same on Cygwin 3.1.4 and Apache Thrift 0.12.0. I would be very grateful for your help Raimund Paulus -- Problem reports: https://cygwin.com/problems.html FAQ: https://cygwin.com/faq/ Documentation: https://cygwin.com/docs.html Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple