I know the reason. Because I use thrift 0.5.0, this is a bug in 0.5.0 Thanks very much.
--Hassan Chen On Wed, Apr 17, 2013 at 6:09 PM, Hassan Chen <[email protected]> wrote: > Hi, below is my source. But when I exceute it, the error happen: > -------Thrift: Wed Apr 17 17:52:42 2013 TConnection:transition() > Negative frame size 0, remote side not using TFramedTransport > > ///////////////////////////// > source code > server cpp: > int main(int argc, char **argv) { > int port = 9060; > shared_ptr<BookOrderHandler> handler(new BookOrderHandler(argv[1])); > shared_ptr<TProcessor> processor(new BookOrderProcessor(handler)); > > TNonblockingServer server(processor, port); > server.serve(); > return 0; > } > > client php: > try{ > > $socket = new TSocket('192.168.0.31', 9060); > $transport = new TFramedTransport($socket); > $protocol = new TBinaryProtocolAccelerated($transport); > $client = new BookOrderClient($protocol); > > $transport->open(); > > $result = $client->order("my book order"); > $transport->close(); > }catch (TException $tx) { > print 'TException: '.$tx->getMessage()."/n"; > } > > Is it a bug? or TBinaryProtocolAccelerated doesn't support > TFramedTransport? > > > On Wed, Apr 17, 2013 at 6:05 PM, Hassan Chen <[email protected]> wrote: > >> Hi, >> >> >> On Wed, Apr 17, 2013 at 4:38 PM, Matthew Chambers <[email protected] >> > wrote: >> >>> >>> What I do for python is generate C++ code and put cython bindings around >>> it, much faster. (over10x) You could do the same thing for PHP by writing >>> a PHP extension. >>> >>> Start here: >>> http://www.php.net/manual/en/**internals2.php<http://www.php.net/manual/en/internals2.php> >>> >>> You could also try something like Swig which is like an auto bindings >>> generator for many languages. >>> >>> -Matt >>> >>> >>> On 17/04/13 20:33, Hassan Chen wrote: >>> >>>> Have any way to improve it ? Google tell me nothing. >>>> >>>> >>>> On Wed, Apr 17, 2013 at 4:30 PM, Matthew Chambers < >>>> [email protected]>wrote: >>>> >>>> Yes, because PHP is an interpreted language. >>>>> >>>>> >>>>> On 17/04/13 20:27, Hassan Chen wrote: >>>>> >>>>> o(╯□╰)o, about 17999 books. This only a test. In practical >>>>>> applications, I >>>>>> also transfer the array data like this but not books. >>>>>> Buy I found when transfer large amounts of data one-time, php is very >>>>>> slow. >>>>>> Can you tell me why? >>>>>> >>>>>> >>>>>> On Wed, Apr 17, 2013 at 4:20 PM, Matthew Chambers < >>>>>> [email protected] >>>>>> >>>>>>> wrote: >>>>>>> >>>>>> How much roughly would 829k worth of books cost? Are you preparing >>>>>> for >>>>>> >>>>>>> people to order the entire amazon library through your interface? >>>>>>> >>>>>>> >>>>>>> On 17/04/13 20:06, Hassan Chen wrote: >>>>>>> >>>>>>> Hi, >>>>>>> >>>>>>>> Now I'm using TNonblockingServer. But I found php is so slow than >>>>>>>> cpp. >>>>>>>> >>>>>>>> The testing result: >>>>>>>> >>>>>>>> server client data size time >>>>>>>> cpp php 829K 2m23.110s >>>>>>>> cpp php 446K 0m33.337s >>>>>>>> cpp php 199K 0m4.305s >>>>>>>> cpp cpp 829K 0m0.564s >>>>>>>> >>>>>>>> The service and data struct is: >>>>>>>> struct Book { >>>>>>>> 1: i32 book_id, >>>>>>>> 2: string book_name, >>>>>>>> 3: string book_author, >>>>>>>> 4: double book_price, >>>>>>>> 5: string book_publisher, >>>>>>>> 6: i32 age, >>>>>>>> } >>>>>>>> >>>>>>>> service BookOrder { >>>>>>>> list<Book> order(1: string book); >>>>>>>> } >>>>>>>> >>>>>>>> >>>>>>>> Now I have some question: >>>>>>>> 1. Why php is so much slower than cpp >>>>>>>> 2. As the amount of data increases, the php's performance >>>>>>>> drastically >>>>>>>> reduced >>>>>>>> >>>>>>>> can anyone tell me? >>>>>>>> >>>>>>>> Thanks. >>>>>>>> -- >>>>>>>> Hassan Chen >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>> >> >
