Hi Juan,
- *sa_len = sizeof(struct sockaddr_in); - memset( sa, 0, sizeof(struct sockaddr_in) ); - memcpy( &((struct sockaddr_in *)sa)->sin_addr, &((struct sockaddr_in *)res->ai_addr)->sin_addr, sizeof(struct in_addr) ); - ((struct sockaddr_in *)sa)->sin_family = res->ai_family; - ((struct sockaddr_in *)sa)->sin_port = htons( port ); + *sa_len = res->ai_addrlen; + memcpy( sa, res->ai_addr, res->ai_addrlen );
This causes test failures, you can't ignore the port.
-Hans