int OsSSLConnectionSocket::read(char* buffer, int bufferLength, UtlString* ipAddress, int* port) { // Overide base class version as recvfrom does not // seem to return host info correctly for TCP // Use base class version without the remote host info int bytesRead = -1; bytesRead = SSL_read (mSSL, buffer, bufferLength); #ifdef VALGRIND_MAKE_READABLE // If we are using Valgrind, we have to compensate for the fact that // Valgrind thinks all the output of SSL_read is undefined. // (This probably comes from SSL's use of uninitialized memory as part // of its key-generation algorithm.) VALGRIND_DISCARD(VALGRIND_MAKE_READABLE(&bytesRead, sizeof (bytesRead))); if (bytesRead > 0) { VALGRIND_DISCARD(VALGRIND_MAKE_READABLE(buffer, bytesRead)); } #endif /* VALGRIND_MAKE_READABLE */ // Explicitly get the remote host info. getRemoteHostIp(ipAddress); *port = getRemoteHostPort(); return(bytesRead); }
void OsSocket::getRemoteHostIp(UtlString* remoteHostAddress, int* remotePort) { struct in_addr remoteAddr; getRemoteHostIp(&remoteAddr, remotePort); remoteHostAddress->remove(0); inet_ntoa_pt(remoteAddr, *remoteHostAddress); // If querying the network layer did not obtain an address (probably // because the socket is still in the process of connecting), return // the values stored from the connect attempt. if (remoteHostAddress->compareTo("0.0.0.0") == 0) { remoteHostAddress->remove(0); remoteHostAddress->append(mRemoteIpAddress); if (remotePort) { *remotePort = remoteHostPort; } } }