From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mailrelay.dillinger.de (mailrelayb.dillinger.de [212.184.64.29]) by sourceware.org (Postfix) with ESMTPS id 78505385E000 for ; Wed, 25 Mar 2020 09:04:12 +0000 (GMT) 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.Paulus@dillinger.biz Received: from mailrelaya2.dillinger.de (mailrelaya [192.168.175.11]) by lin254mailrelayb.dillinger.de (Postfix) with ESMTP id E9073A348 for ; Wed, 25 Mar 2020 10:04:10 +0100 (CET) Received: from lin275.int.shsservices.de (lin275 [172.18.32.6]) by mailrelaya2.dillinger.de (Postfix) with ESMTP id B6FB8242474 for ; Wed, 25 Mar 2020 10:09:12 +0100 (CET) Received: from resw123.resdom01.local (resw123.dillinger.de [172.18.22.123]) by lin275.int.shsservices.de (Postfix) with ESMTP id DA3C3F3BA0 for ; Wed, 25 Mar 2020 10:04:10 +0100 (CET) Received: from resw122.resdom01.local (172.18.22.122) by resw123.resdom01.local (172.18.22.123) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 25 Mar 2020 10:04:10 +0100 Received: from resw122.resdom01.local ([fe80::4dd9:f975:1c16:f521]) by resw122.resdom01.local ([fe80::4dd9:f975:1c16:f521%14]) with mapi id 15.00.1473.003; Wed, 25 Mar 2020 10:04:10 +0100 From: "PAULUS, Raimund, TI-ABN" To: "'cygwin@cygwin.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] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable 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@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Mar 2020 09:04:14 -0000 Problems using Qt5 and Apache Thrift For several months i use Apache Thrift 0.11.0 on Cygwin 2.5.2 for data tran= sfer between Windows boxes and my Linux host. On the Windows boxes a C++-ap= plication serves as a client. The user makes some input on an ascii-interfa= ce (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 prog= ram 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 connecti= on 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 serv= ice on the linux box is created from CppServer.cpp. The client in the origi= nal is CppClient.cpp. But I modified it for Qt. Here is the source for CppC= lient.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(socke= t)); 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 =3D new QWidget(); 63 64 printf("Stop 3; Press to continue"); getchar(); 65 66 QPushButton *b_end =3D 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 =3D "); 84 txt.append(QString::number(client.add(1, 1))); 85 MsgBox(txt.toStdString().c_str()); 86 87 Work work; 88 work.op =3D Operation::DIVIDE; 89 work.num1 =3D 1; 90 work.num2 =3D 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 =3D Operation::SUBTRACT; 103 work.num1 =3D 15; 104 work.num2 =3D 10; 105 int32_t diff =3D client.calculate(1, work); 106 txt.clear(); 107 txt.append("15 - 10 =3D "); 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