[Jsonrpc-cpp-devel] Fix to adapt IPV6 and IPV4 on same socket
Brought to you by:
s-vincent
From: Anoop R. <ano...@gm...> - 2015-12-18 07:01:58
|
Hi, I could find a bug in jsonrpc-cpp module while trying to adopt ipv6 capability to my application. I tried to bind my server application to all ip addresses (ipv4 and v6 at the same time) using “::”. I found a comment line in “src/networking.cpp” which says “accept IPv6 OR IPv4 on the same socket”. As the comment says, the server socket should accept both V4 and V6 in the same socket. So I tried to communicate to my server application using its IPV4 address, It didn’t work while connecting with its V6 counterpart was working. This made me peek into networking.cpp source code to see the socket options. In “setsockopt()”, a parameter decides the flexibility of the socket to accept both ip versions or not. on = 1; setsockopt(sock, IPPROTO_IPV6,IPV6_V6ONLY, &on, sizeof(on)); Here the variable is set to value ‘1’, which doesn’t allow both ip versions simultaneously. This contradicts with the comment given there. on = 0; setsockopt(sock, IPPROTO_IPV6,IPV6_V6ONLY, &on, sizeof(on)); Instead its value should be ‘0’. Modifying this value made my application work as expected. I think this is a bug in the implementation. I couldn’t find any bugzilla or other bug tracking tools. Hence posting it here. Best Regards, Anoop Ravi |