I want to get the IP address of the client on SSL server with the following code,
int sock;
sock = SSL_get_fd(s); // s is a type of SSL, sock returns right value
struct sockaddr_in peer;
socklen_t peer_len = sizeof(peer);
int ret = getpeername(sock, (struct sockaddr *) &peer, &peer_len);
Here ret is 0, but peer address is
(gdb) print peer
$16 = {sin_family = 10, sin_port = 37604, sin_addr = {s_addr = 0}, sin_zero = "\000\000\000\000\000\000\000"}
Look the sin_family value is 10, that is AF_INET6, and s_addr is 0. However the client makes connection to server on IPv4.
apps/openssl s_server and s_client are used as server and client.
This is very weird, any ideas?
Many thanks,
/Kaiduan