thrift-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Jenkins <peter4...@gmail.com>
Subject Re: Thrift socket behaves different in C and PHP
Date Fri, 18 Nov 2011 03:59:50 GMT
UNSUBSCRIBE

Sent from my iPhone

On Nov 17, 2011, at 5:11 PM, Cheng-Han Tsai <chenghan.tsai@gmail.com> wrote:

> Hi all,
> 
> I solve this problem, but I am sure about the root cause...
> 
> The problem seems to be getaddrinfo doesn't return correct info.
> As the following codes indicates, I remove AI_ADDRCONFIG in ai_flags.
> C++ clients is then able to connect to php server.
> 
> TSocket.cpp:
> ...
>  hints.ai_family = PF_UNSPEC;
>  hints.ai_socktype = SOCK_STREAM;
>  //hints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG;
>  hints.ai_flags = AI_PASSIVE;
>  sprintf(port, "%d", port_);
> 
>  error = getaddrinfo(host_.c_str(), port, &hints, &res0);
> ...
> 
> The man page said:
> 
>       If hints.ai_flags includes the AI_ADDRCONFIG flag, then IPv4
> addresses are returned in the list pointed to by res only if the local
> system has
>       at least one IPv4 address configured, and IPv6 addresses are only
> returned if the local system has at least one IPv6 address configured.
> 
> However, my system got both IPv4 and IPv6 address.
> This should not be a problem....
> 
> eth0      Link encap:Ethernet  HWaddr 00:13:d4:e4:65:ed
>          inet addr:192.168.1.25  Bcast:192.168.1.255  Mask:255.255.255.0
>          inet6 addr: fe80::213:d4ff:fee4:65ed/64 Scope:Link
>          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
>          RX packets:821282 errors:0 dropped:0 overruns:0 frame:0
>          TX packets:958548 errors:0 dropped:0 overruns:0 carrier:0
>          collisions:0 txqueuelen:1000
>          RX bytes:122517133 (122.5 MB)  TX bytes:253954816 (253.9 MB)
>          Interrupt:17 Base address:0xe000
> 
> lo        Link encap:Local Loopback
>          inet addr:127.0.0.1  Mask:255.0.0.0
>          inet6 addr: ::1/128 Scope:Host
>          UP LOOPBACK RUNNING  MTU:16436  Metric:1
>          RX packets:75224 errors:0 dropped:0 overruns:0 frame:0
>          TX packets:75224 errors:0 dropped:0 overruns:0 carrier:0
>          collisions:0 txqueuelen:0
>          RX bytes:23526262 (23.5 MB)  TX bytes:23526262 (23.5 MB)
> 
> 
> Anyway, the problem solved.
> It would be fantastic if I could know the root cause.
> 
> Thanks,
> 
> -- 
> Keene Tsai (蔡承翰)
> http://keene.twbbs.org
> 
> 
> On Fri, Nov 18, 2011 at 4:38 AM, Cheng-Han Tsai <chenghan.tsai@gmail.com>wrote:
> 
>> Hi all,
>> 
>> I am not sure if this is a bug.
>> I wrote a PHP standalone server (w/ TSimpleServer) by modifying php
>> tutorial codes.
>> The tutorial version of php client could connect to the standalone php
>> server successfully.
>> All execution results are correc as expected.
>> However, c++ client can't even establish the connection.
>> The error message is listed:
>> 
>> Thrift: Fri Nov 18 04:13:36 2011 TSocket::open() connect() <Host:
>> localhost Port: 9090>Connection refused
>> Thrift: Fri Nov 18 04:13:36 2011 TSocket::open() connect() <Host:
>> localhost Port: 9090>Connection refused
>> ERROR: connect() failed: Connection refused
>> 
>> Telnet shows port 9090 is available, but c++ client still have problem to
>> connect.
>> I also confirmed that c++ server/client works perfectly in the same
>> environment.
>> Therefore, I am thinking if the implementation of C and PHP version have
>> compatibility problem
>> 
>> The main implementation of my php standalone server is listed below.
>> 
>> $handler = new CalculatorHandler();
>> $processor = new CalculatorProcessor($handler);
>> $transport = new TServerSocket();
>> $i_transportFactory = new TTransportFactory();
>> $o_transportFactory = new TTransportFactory();
>> $i_protocolFactory = new TBinaryProtocolFactory();
>> $o_protocolFactory = new TBinaryProtocolFactory();
>> 
>> $simple_server = new TSimpleServer($processor, $transport,
>> $i_transportFactory, $o_transportFactory, $i_protocolFactory,
>> $o_protocolFactory);
>> 
>> print "server to start\n";
>> $simple_server->serve();
>> 
>> 
>> Any idea?
>> 
>> 
>> Best Regards,
>> 
>> --
>> Keene Tsai (蔡承翰)
>> http://keene.twbbs.org
>> 

Mime
View raw message