Fix IPv6 support (sockaddr size)
Since struct sockaddr is too small to contain an IPv6, we use struct sockaddr_in6 instead, and we cast it where needed
This commit is contained in:
@@ -140,7 +140,7 @@ void SocketHandler::connect(const std::string& address, const std::string& port,
|
||||
this->ai_addrlen = rp->ai_addrlen;
|
||||
memcpy(&this->ai_addr, rp->ai_addr, this->ai_addrlen);
|
||||
memcpy(&this->addrinfo, rp, sizeof(struct addrinfo));
|
||||
this->addrinfo.ai_addr = &this->ai_addr;
|
||||
this->addrinfo.ai_addr = reinterpret_cast<struct sockaddr*>(&this->ai_addr);
|
||||
this->addrinfo.ai_next = nullptr;
|
||||
// If the connection has not succeeded or failed in 5s, we consider
|
||||
// it to have failed
|
||||
|
||||
@@ -199,7 +199,7 @@ private:
|
||||
* again.
|
||||
*/
|
||||
struct addrinfo addrinfo;
|
||||
struct sockaddr ai_addr;
|
||||
struct sockaddr_in6 ai_addr;
|
||||
socklen_t ai_addrlen;
|
||||
|
||||
protected:
|
||||
|
||||
Reference in New Issue
Block a user