Found the bug which caused failure of getpeername code.

This commit is contained in:
lotodore
2009-04-11 09:49:05 +00:00
parent c732bd28f0
commit 66da20d2db
+6 -1
View File
@@ -37,7 +37,12 @@ socket_string_to_addr(const char *str, int addrFamily, struct sockaddr *addr, in
bool
socket_addr_to_string(struct sockaddr *addr, int /*addrLen*/, int addrFamily, char *str, int strLen)
{
return (inet_ntop(addrFamily, addr, str, strLen) != NULL);
if (addrFamily == AF_INET)
return (inet_ntop(addrFamily, &((struct sockaddr_in *)addr)->sin_addr, str, strLen) != NULL);
else if (addrFamily == AF_INET6)
return (inet_ntop(addrFamily, &((struct sockaddr_in6 *)addr)->sin6_addr, str, strLen) != NULL);
else
return false;
}
bool