VBool VSocket::SendExact(const char *buff, const VCard bufflen) { struct fd_set write_fds; struct timeval tm; int count; // Put the data into the queue SendQueued(buff, bufflen); while (out_queue) { // Wait until some data can be sent do { FD_ZERO(&write_fds); FD_SET((unsigned int)sock, &write_fds); tm.tv_sec = 1; tm.tv_usec = 0; count = select(sock + 1, NULL, &write_fds, NULL, &tm); } while (count == 0); if (count < 0 || count > 1) { vnclog.Print(LL_SOCKERR, VNCLOG("socket error in select()\n")); return VFalse; } // Actually send some data if (FD_ISSET((unsigned int)sock, &write_fds)) { if (!SendFromQueue()) return VFalse; } } return VTrue; }
VBool CurlSocket::SendExact(const char *buff, const VCard bufflen) { // Put the data into the queue SendQueued(buff, bufflen); while (!out_queue.empty()) { // Actually send some data if (!SendFromQueue()) { return VFalse; } } return VTrue; }
VBool VSocket::SendExactQueue(const char *buff, const VCard bufflen) { if (sock==-1) return VFalse; //adzm 2010-09 if (bufflen <=0) { return VTrue; } // vnclog.Print(LL_SOCKERR, VNCLOG("SendExactQueue %i %i\n") ,bufflen,queuebuffersize); // vnclog.Print(LL_SOCKERR, VNCLOG("socket size %i\n") ,bufflen); // sf@2002 - DSMPlugin VCard nBufflen = bufflen; char* pBuffer = NULL; if (m_fUsePlugin && m_pDSMPlugin->IsEnabled()) { // omni_mutex_lock l(m_TransMutex); // If required to store data into memory if (m_fWriteToNetRectBuf) { memcpy((char*)(m_pNetRectBuf + m_nNetRectBufOffset), buff, bufflen); m_nNetRectBufOffset += bufflen; return VTrue; } else // Tell the plugin to transform data { int nTransDataLen = 0; //adzm 2009-06-20 pBuffer = (char*)(TransformBuffer((BYTE*)buff, bufflen, &nTransDataLen)); if (pBuffer == NULL || (bufflen > 0 && nTransDataLen == 0)) { // throw WarningException("SendExact: DSMPlugin-TransformBuffer Error."); } nBufflen = nTransDataLen; } } else pBuffer = (char*) buff; VInt result=SendQueued(pBuffer, nBufflen); return result == (VInt)nBufflen; }