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 18ABF385B835 for ; Tue, 31 Mar 2020 05:39:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 18ABF385B835 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 06EB7A33C for ; Tue, 31 Mar 2020 07:39:41 +0200 (CEST) Received: from lin275.int.shsservices.de (lin275 [172.18.32.6]) by mailrelaya2.dillinger.de (Postfix) with ESMTP id 23F72242307 for ; Tue, 31 Mar 2020 07:44:45 +0200 (CEST) Received: from resw124.resdom01.local (resw124.dillinger.de [172.18.22.124]) by lin275.int.shsservices.de (Postfix) with ESMTP id EDB30F3D75 for ; Tue, 31 Mar 2020 07:39:41 +0200 (CEST) Received: from resw122.resdom01.local (172.18.22.122) by resw124.resdom01.local (172.18.22.124) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 31 Mar 2020 07:39:41 +0200 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; Tue, 31 Mar 2020 07:39:41 +0200 From: "PAULUS, Raimund, TI-ABN" To: "cygwin@cygwin.com" Subject: Re: Problems using Qt5 and Apache Thrift Thread-Topic: Problems using Qt5 and Apache Thrift Thread-Index: AdYHHlmeqoZEjLByQX2+3fmfWANEuw== Date: Tue, 31 Mar 2020 05:39:41 +0000 Message-ID: <0211a4f2fd564f41a5722b33586e8c02@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="iso-8859-1" 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=-6.7 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, TXREP 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: Tue, 31 Mar 2020 05:39:45 -0000 In the meantime i tested using a thread for the Thrift-connection to my ser= vice.=20 If the thread is started, messages are sent in a loop to the service and a = sleep() is included so that i have enough time to check the connection via = netstat command. The result is the same as in my first attempt. The network connection is br= oken after line 27 (create the QPushButton) in main.cpp. The thread prints = the error message: "Thrift: Mon Mar 30 18:45:27 2020 TSocket::write_partial() send() Broken pipe" Here are the sources: main.cpp: 1 #include 2 3 #include 4 #include 5 #include 6 #include 7 8 #include "thrift_clnt.hpp" 9 10 int main(int argc, char **argv) { 11 12 printf("Stop 1; Press to continue"); getchar(); 13 14 QApplication app(argc, argv); 15 16 QThread* thread =3D new QThread(); 17 ThriftClnt* thrift_cl =3D new ThriftClnt; 18 thrift_cl->moveToThread(thread); 19 QObject::connect(thread, SIGNAL(started()), thrift_cl, SLOT (proc= ess())); 20 QObject::connect(thrift_cl, SIGNAL (finished()), thread, SLOT (qu= it())); 21 QObject::connect(thrift_cl, SIGNAL (finished()), thrift_cl, SLOT = (deleteLater())); 22 QObject::connect(thread, SIGNAL (finished()), thread, SLOT (delet= eLater())); 23 thread->start(); 24 25 printf("Stop 2; Press to continue"); getchar(); 26 27 QPushButton *b_end =3D new QPushButton("End"); 28 29 printf("Stop 3; Press to continue"); getchar(); 30 31 QObject::connect(b_end, SIGNAL(clicked()), &app, SLOT(quit())); 32 33 printf("Stop 4; Press to continue"); getchar(); 34 35 b_end->show(); 36 37 printf("Stop 6; Press to continue"); getchar(); 38 39 app.exec(); 40 41 thread->wait(); // do not exit before the thread is completed! 42 43 } thrift_clnt.hpp: 1 #ifndef __THRIFT_CLNT_HPP 2 #define __THRIFT_CLNT_HPP 3 4 #include 5 6 class ThriftClnt : public QObject 7 { 8 Q_OBJECT 9 10 public: 11 ThriftClnt(); 12 ~ThriftClnt(); 13 14 public slots: 15 void process(); 16 17 signals: 18 void finished(); 19 void error(QString err); 20 21 private: 22 // add your variables here 23 }; 24 25 #endif // __THRIFT_CLNT_HPP thrift_clnt.cpp: 1 #include "thrift_clnt.hpp" 2 3 #include 4 #include 5 #include 6 #include 7 8 #include "../gen-cpp/Calculator.h" 9 10 using namespace std; 11 using namespace apache::thrift; 12 using namespace apache::thrift::protocol; 13 using namespace apache::thrift::transport; 14 15 using namespace tutorial; 16 using namespace shared; 17 18 ThriftClnt::ThriftClnt() { 19 } 20 21 ThriftClnt::~ThriftClnt() { 22 } 23 24 void ThriftClnt::process() 25 { 26 27 stdcxx::shared_ptr socket(new TSocket("192.168.178.20= 0", 9090)); 28 // stdcxx::shared_ptr socket(new TSocket("localhost", = 9090)); 29=20 30 stdcxx::shared_ptr transport(new TBufferedTransport(s= ocket)); 31 stdcxx::shared_ptr protocol(new TBinaryProtocol(transp= ort)); 32 33 CalculatorClient client(protocol); 34 35 try { 36 transport->open(); 37 38 char txt[128]; 39 for(int i=3D1; 1<20; i++) 40 { 41 sprintf(txt, "%d + %d =3D %d", i, i, client.add(i, i)); 42 sleep(5); 43 } 44 45 } catch (TException& tx) { 46 printf("ERROR: %s\n", tx.what()); 47 } 48 49 emit finished(); 50 } 51 QT-Thrift.pro: 1 ###################################################################= ### 2 # Automatically generated by qmake (3.0) Mo. M=E4rz 23 15:29:31 202= 0 3 ###################################################################= ### 4 5 QT +=3D core gui widgets 6 7 TEMPLATE =3D app 8 TARGET =3D QtClient 9 INCLUDEPATH +=3D . 10 INCLUDEPATH +=3D ../gen-cpp 11 12 linux: { 13 TOOLS_DIR =3D /software/tools 14 } 15 16 cygwin: { 17 TOOLS_DIR =3D /cygdrive/e/Software/Cygwin/2_5_2-tools 18 } 19 20 # directories for thrift 21 TOOLS_INCL =3D $${TOOLS_DIR}/include 22 TOOLS_LIB =3D $${TOOLS_DIR}/lib 23 24 INCLUDEPATH +=3D $${TOOLS_INCL} 25 26 LIBS +=3D -L $${TOOLS_LIB} -lthrift 27 28 # Input 29 HEADERS +=3D thrift_clnt.hpp ../gen-cpp/Calculator.h 30 31 SOURCES +=3D main.cpp thrift_clnt.cpp \ 32 ../gen-cpp/Calculator.cpp \ 33 ../gen-cpp/SharedService.cpp \ 34 ../gen-cpp/shared_constants.cpp \ 35 ../gen-cpp/shared_types.cpp \ 36 ../gen-cpp/tutorial_constants.cpp \ 37 ../gen-cpp/tutorial_types.cpp \ The modules in directory gen-cpp are built with the Thrift compiler in Linu= x. The Thrift libs are built in Cygwin after unpacking the tar ball thrift-= 0.11.0.tar.gz with the commands: >./bootstrap.sh >export CXXFLAGS=3D"-D_HAVE_SYS_TIME_H -DPTHREAD_MUTEX_RECURSIVE_NP=3DPTHRE= AD_MUTEX_RECURSIVE -O2 -std=3Dgnu++11 -D_GNU_SOURCE" >./configure --with-qt4=3Dno --with-qt5=3Dno --with-csharp=3Dno --with-java= =3Dno \ --with-erlang=3Dno --with-nodejs=3Dno --with-lua=3Dno --with-python=3Dno = --with-perl=3Dno \ --with-php=3Dno --with-php_extension=3Dno --with-dart=3Dno --with-ruby=3D= no --with-haskell=3Dno \ --with-go=3Dno --with-rs=3Dno --with-cl=3Dno --with-haxe=3Dno --with-dotn= etcore=3Dno --with-d=3Dno \ --disable-tests --prefix=3D/cygdrive/e/Software/Cygwin/2_5_2-tools > make > make install Greetings Raimund Paulus > -----Urspr=FCngliche Nachricht----- > Von: Cygwin [mailto:cygwin-bounces@cygwin.com] Im Auftrag von PAULUS, > Raimund, TI-ABN > Gesendet: Donnerstag, 26. M=E4rz 2020 07:59 > An: 'cygwin@cygwin.com' > Betreff: Re: Problems using Qt5 and Apache Thrift >=20 > Hello Andrey Repin >=20 > The sources and the documentation are her: >=20 > https://thrift.apache.org/tutorial/cpp >=20 > You must have libthrift installed. >=20 > Maybe using threads is a better programming style, but i don't know, if i= t solves the > problem. I use connecting and disconnecting to the service like braces ar= ound the > rest of the application. At some points the application transfers data to= the service > and expects an answer. It is a synchronous communication and i use it lik= e RPC > (remote procedure call). The client sends a request and the service has t= o respond. > Without the response the client cannot continue. Every client has its own= service. >=20 > Greetings >=20 > Ramund Paulus >=20 > > -----Urspr=FCngliche Nachricht----- > > Von: Andrey Repin [mailto:anrdaemon@yandex.ru] > > Gesendet: Mittwoch, 25. M=E4rz 2020 12:13 > > An: PAULUS, Raimund, TI-ABN; cygwin@cygwin.com > > Betreff: Re: Problems using Qt5 and Apache Thrift > > > > Greetings, PAULUS, Raimund, TI-ABN! > > > > > Problems using Qt5 and Apache Thrift > > > > ...snip... > > > > > Now i want to implement the interface parts with Qt 5. Here is the ne= w 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 s= ee it > > > with the netstat command. First error message arises in step 4: > > > > > "TSocket::write_partial() send() Broken pip= e" > > > > I strongly suggest placing communication service in its own thread. > > Then you could manage connection without having to worry about blocking > > timeouts caused by GUI operations. > > They will run asynchronously. > > > > > On a Linux box the client program runs perfectly. > > > > Only by coincidence, I suppose. > > > > > 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 c= reated > > > and i can not close and create the connection at each point. > > > > I suppose, the server dropping connection by timeout. But I'd urge you = to > > investigate this further. > > > > > For the tests I used the examples from the Apache Thrift Tutorial. > > > > Please include examples as text/plain attachments, if they are longer t= han a > > few lines. > > > > > > -- > > With best regards, > > Andrey Repin > > Wednesday, March 25, 2020 14:08:25 > > > > Sorry for my terrible english... >=20 > -- > 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 >=20