This function is used to obtain the peer's socket address information on a connected socket. The function is defined as
int getpeername( SOCKET s, struct sockaddr FAR* name, int FAR* namelen );
The first parameter is the socket for the connection; the last two parameters are a pointer to a SOCKADDR structure of the underlying protocol type and its length. For datagram sockets, this function returns the address passed to a connect call; however, it will not return the address passed to a sendto or WSASendTo call.
From:Network Programming for Microsoft Windows 2nd.CHM