/* Compares two addresses contained into two sockaddr_storage structures. 
This function will return '0' if the two addresses matches, '-1' if not. */
int sock_cmpaddr(struct sockaddr_storage *first, struct sockaddr_storage *second)
/* Compares two addresses contained into two sockaddr_storage structures. 
This function will return '0' if the two addresses matches, '-1' if not. */
int sock_cmpaddr(struct sockaddr_storage *first, struct sockaddr_storage *second)
{
	if (first->ss_family == second->ss_family)
	{
		if (first->ss_family == AF_INET)
		{
			if (memcmp(&(((struct sockaddr_in *) first)->sin_addr),
				&(((struct sockaddr_in *) second)->sin_addr),
				sizeof(struct in_addr)) == 0)
				return 0;
		}
		else
		{
			if (memcmp(&(((struct sockaddr_in6 *) first)->sin6_addr),
				&(((struct sockaddr_in6 *) second)->sin6_addr),
				sizeof(struct in6_addr)) == 0)
				return 0;
		}
	}
	return -1;
}