unsigned long CIpSocket::Send( const void *x_pData, unsigned long x_uSize, unsigned long *x_puSent, unsigned long x_uFlags ) { // Initialize bytes sent if ( x_puSent ) *x_puSent = 0; // Must have a socket handle if ( !IsSocket() ) return 0; // Attempt to send the data setWouldBlock( 0 ); int nRet = v_send( (SOCKET)m_hSocket, x_pData, (int)x_uSize, (int)x_uFlags ); // Get the last error code m_uLastError = WSAGetLastError(); if ( WSAEWOULDBLOCK == m_uLastError ) m_uLastError = 0; m_uWrites++; m_lActivity++; // Check for error if ( SOCKET_ERROR == nRet || 0 > nRet ) { // Is the socket blocking? if ( !getWouldBlock() && m_uLastError ) { m_uConnectState |= eCsError; return 0; } // end if // Not an error m_uConnectState &= ~eCsError; // Number of bytes sent if ( x_puSent ) *x_puSent = 0; // no bytes sent return 0; } // end if // Save the number of bytes sent if ( x_puSent ) *x_puSent = nRet; return nRet; }
int CSqSSLPortFactory::CSqSSLPort::v_send( int socket, const void *buffer, int length, int flags ) {_STT(); oexAutoLock ll( m_lock ); if ( !ll.IsLocked() ) return 0; int ret = SSL_write( m_ssl, buffer, length ); if ( 0 > ret && SSL_ERROR_WANT_WRITE == SSL_get_error( m_ssl, ret ) ) { setWouldBlock( oex::oexTRUE ); return -1; } // end if return ret; }