cvg_bool TcpSocket::getRemoteAddress(IAddress &addr) { InetAddress *iaddr = dynamic_cast<InetAddress *>(&addr); if (iaddr == NULL) throw cvgException("[TcpSocket] The address provided to getRemoteAddress() is not of type InetAddress"); struct sockaddr_in addrIn; socklen_t addrLen = sizeof(struct sockaddr_in); if (getpeername(descriptor, (struct sockaddr *)&addrIn, &addrLen) != 0) throw cvgException("[TcpSocket] Unable to get remote address"); iaddr->fromAddr(addrIn); }