/*! \internal Writes \a len bytes to the socket from \a data and returns the number of bytes written. Returns -1 if an error occurred. */ Q_LONG cAsyncNetIOPrivate::writeBlock( const char* data, Q_ULONG len ) { // Invalid Socket -> Disconnected if ( !socket->isValid() ) { socket->close(); return 0; } if ( len == 0 ) return 0; QByteArray* a = wba.last(); if ( a && a->size() + len < 128 ) { // small buffer, resize int i = a->size(); a->resize( i + len ); memcpy( a->data() + i, data, len ); } else { // append new buffer a = new QByteArray( len ); memcpy( a->data(), data, len ); wba.append( a ); } wsize += len; return len; }
void QSocketPrivate::closeSocket() { // Order is important here - the socket notifiers must go away // before the socket does, otherwise libc or the kernel will // become unhappy. delete rsn; rsn = 0; delete wsn; wsn = 0; if ( socket ) socket->close(); }