My guess is:
getsockname returns the IP address of where the socket lives, i.e., the host it's connected to, in this case localhost. ie., the LOCAL address of the socket.
I'm guessing you want something else. mac address?
Normally there are two computers involved in a socket. getsockname gets the IP address of the local endpoint of the socket. getpeername gets the IP address at the other end. When client and server both run of the same box, both calls can return 127.0.0.1 but that is a special case.
You're correct, but I'm still not sure that's what he wants.
If he wanted getpeername() that's what he should call. He seems to know about it.
I know some implementations don't support X25 AF_CCITT (XOPEN standards).