gbuddappagari / mock_client Goto Github PK
View Code? Open in Web Editor NEWClient to communicate with parodus
License: Apache License 2.0
Client to communicate with parodus
License: Apache License 2.0
Thanks for reply, I agree with your point. But if you see at line 154 in client-handshake.c, even though you iterate inside loop for Ipv4 address, returned from getaddrinfo, once it returns first Ip then you are coming out from loop by doing break, that means connect() will always try to connect with first address returned from getaddrinfo (even if it get fails due to some temporary network failure reason) and it will never try to do connect() with other address returned from getaddrinfo.
My proposal is something like below for dual network scenario,
#ifdef DUAL_NETWORK_ENABLE
hints.ai_family = AF_UNSPEC; /*Ipv6 or ipv4*/
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = 0;
hints.ai_flags = AI_ADDRCONFIG;
/* resolving host name */
retVal = getaddrinfo(host, port, &hints, &result);
if (retVal != 0){
/* getaddrinfo FAILED */
return -1;
}
else
{
/* iterate all address either Ipv6 or Ipv4 returned from getaddrinfo till connect() success*/
while(ip_is_present)
{
if(rp->ai_family == AF_INET)
/* getaddrinfo resolved Ipv4 address, Try connect with IPv4 mode */
else if(rp->ai_family == AF_INET6)
/* getaddrinfo resolved Ipv6 address, Try connect with IPv6 mode */
session = socket(rp->ai_family, rp->ai_socktype, 0);
if (session == FAILURE)
/* FAILED to create socket, Try again with other address */
continue;
else
/* SUCCESS socket created successfully */
if (connect(session, rp->ai_addr, rp->ai_addrlen) < 0)
{
if(errno != SOME_ERRNO_CHECK)
/* here close socket and retry the connection*/
return -1;
else
/* Retry again with other address returned from getaddrinfo */
}
else
{
/* Connect is successfull, you can continue with handshake */
break;
}
}
#endif
The reason behind above code is, in my dual stack network case sometimes Ipv6 connection will get fail or refused in some network ip range. So in this case even Ipv4 mapped Ipv6 address also will get fail. If we try with Ipv4 connect then it will connect successfully.
Please check above code and provide your comments. If you feel any additional changes or improvements required then I'm ready to work on that.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.