Logo Search packages:      
Sourcecode: znc version File versions

void CDCCSock::ReadData ( const char *  data,
int  len 
) [virtual]

Author:
prozac@rottenboy.com

Reimplemented from Csock.

Definition at line 5 of file DCCSock.cpp.

References Csock::Close(), and Csock::Write().

                                                 {
      if (!m_pFile) {
            DEBUG_ONLY(cout << "File not open! closing get." << endl);
            m_pUser->PutModule(m_sModuleName, ((m_bSend) ? "DCC -> [" : "DCC <- [") + m_sRemoteNick + "][" + m_sFileName + "] - File not open!");
            Close();
      }

      if (m_bSend) {
            m_sSendBuf.append(data, len);

            while (m_sSendBuf.size() >= 4) {
                  unsigned int iRemoteSoFar;
                  memcpy(&iRemoteSoFar, m_sSendBuf.data(), 4);
                  iRemoteSoFar = ntohl(iRemoteSoFar);

                  if ((iRemoteSoFar + 65536) >= m_uBytesSoFar) {
                        SendPacket();
                  }

                  m_sSendBuf.erase(0, 4);
            }
      } else {
            m_pFile->Write(data, len);
            m_uBytesSoFar += len;
            unsigned long uSoFar = htonl(m_uBytesSoFar);
            Write((char*) &uSoFar, sizeof(unsigned long));

            if (m_uBytesSoFar >= m_uFileSize) {
                  Close();
            }
      }
}


Generated by  Doxygen 1.6.0   Back to index