From fdea364bb8773f9d40eb7db44dfce4d2093809e3 Mon Sep 17 00:00:00 2001 From: Kiritow <1362050620@qq.com> Date: Thu, 7 Jun 2018 20:04:28 +0800 Subject: [PATCH] Fix inet_ntop wrong usage --- gsock.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gsock.cpp b/gsock.cpp index bb5a1a5..4c91736 100644 --- a/gsock.cpp +++ b/gsock.cpp @@ -310,7 +310,7 @@ static int _sock_getname_call(int sfd,std::string& ip,int& port,_sock_getname_ca { struct sockaddr_in* paddr = &pack.saddr4; char ip_buff[64] = { 0 }; - const char* pret = inet_ntop(AF_INET, paddr, ip_buff, 64); + const char* pret = inet_ntop(AF_INET, &(paddr->sin_addr), ip_buff, 64); if (pret) { ip = std::string(ip_buff); @@ -327,7 +327,7 @@ static int _sock_getname_call(int sfd,std::string& ip,int& port,_sock_getname_ca { struct sockaddr_in6* paddr = &pack.saddr6; char ip_buff[128] = { 0 }; - const char* pret = inet_ntop(AF_INET6, paddr, ip_buff, 128); + const char* pret = inet_ntop(AF_INET6, &(paddr->sin6_addr), ip_buff, 128); if (pret) { ip = std::string(ip_buff);