コード例 #1
0
void QSocketSession::findByteOrder()
{
	float i = 3.1415;
	if (theIsMaster)
	{	sendChunk((uchar *)&i, 4);
		if (!waitForAck(1000, &theSameByteOrder) || !isOpen())
		{	qWarning("*** ERROR: Handshake failed: Didn't receive ack. Closing link.");
			close();
			return;
		}
	}
	else
	{	float remotei;
		if (!receiveChunk((uchar *)&remotei, 4, 1000) || !isOpen())
		{	qWarning("*** ERROR: Handshake failed: Didn't receive remote bit pattern. Closing link.");
			close();
			return;
		}
		float rremotei;
		uint &t = *((uint *)&rremotei);
		t = bswap_32(*((uint *)&remotei));

		if (remotei == i)
			theSameByteOrder = true;
		else if (rremotei == i)
			theSameByteOrder = false;
		else
			qWarning("*** CRITICAL: Two hosts have neither same nor opposite byte order. (%f or %f should be %f)", remotei, rremotei, i);
		ack(theSameByteOrder);
	}
}
コード例 #2
0
void SMTPChunkingOutputStreamAdapter::write
	(const value_type* const data, const size_type count)
{
	const value_type* curData = data;
	size_type curCount = count;

	while (curCount != 0)
	{
		// Fill the buffer
		const size_type remaining = sizeof(m_buffer) - m_bufferSize;
		const size_type bytesToCopy = std::min(remaining, curCount);

		std::copy(data, data + bytesToCopy, m_buffer + m_bufferSize);

		m_bufferSize += bytesToCopy;
		curData += bytesToCopy;
		curCount -= bytesToCopy;

		// If the buffer is full, send this chunk
		if (m_bufferSize >= sizeof(m_buffer))
		{
			sendChunk(m_buffer, m_bufferSize, /* last */ false);
			m_bufferSize = 0;
		}
	}
}
コード例 #3
0
void SMTPChunkingOutputStreamAdapter::flush()
{
	sendChunk(m_buffer, m_bufferSize, /* last */ true);
	m_bufferSize = 0;

	if (m_progress)
		m_progress->stop(m_totalSize);

	if (m_connection->getTracer())
		m_connection->getTracer()->traceSendBytes(m_bufferSize);
}
コード例 #4
0
ファイル: usbuser.c プロジェクト: Neon22/pixy
void USB_Send(const uint8_t *data, uint32_t len)
{
    if ((uint32_t)data&0x3)
        return;

    g_sendData = data;
    g_sendLen = len;
    g_sendOffset = 0;
    g_sendComplete = 0;

    sendChunk();
}
コード例 #5
0
ファイル: som.c プロジェクト: cskiraly/NAPA-BASELIBS
/** ChunkBuffer notifier: gets called whenever a new Chunk is inserted into
 * the buffer 
 */
void chunkbuffer_notifier(struct chunk_buffer *cb, void* cbarg, const struct
		chunk *c) {
	/* Send the good stuff to all the neighbors */
	int i;
	for (i = 0; i != num_neighbors; i++) {
		if (strcmp(neighbors[i].peer, LocalPeerID)) {
			debug("Sending chunk %u to %s",  chunkGetId(c), neighbors[i].peer);
			sendChunk(neighbors[i].peer, c);
		}
	}

	playout_chunk(c);
}
コード例 #6
0
ファイル: usbuser.c プロジェクト: Neon22/pixy
void USB_EndPoint2 (uint32_t event) {

    switch (event) {
    case USB_EVT_OUT_NAK:
        //bulkOutNak();
        break;
    case USB_EVT_OUT:
        recvChunk();
        break;
    case USB_EVT_IN:  // this gets called upon completion
        sendChunk();
        break;
    }
}
コード例 #7
0
am_status_t
BaseService::sendRequest(Connection& conn,
			 const BodyChunk& headerPrefix,
			 const std::string& uri,
			 const std::string& uriParameters,
			 const Http::HeaderList& headerList,
			 const Http::CookieList& cookieList,
			 const BodyChunk& contentLine,
			 const BodyChunk& headerSuffix,
			 const BodyChunkList& bodyChunkList) const
{
    am_status_t status;
    std::string requestLine(headerPrefix.data);

    requestLine.append(uri);
    requestLine.append(uriParameters);
    requestLine.append(HTTP_VERSION_SUFFIX);

    Log::log(logModule, Log::LOG_MAX_DEBUG,
            "BaseService::sendRequest "
            "Request line: %s", requestLine.c_str());

    status = sendChunk(conn, BodyChunk(requestLine));
    if (AM_SUCCESS == status) {
	std::string cookieLine;
	// XXX - Need to send cookies here.
        
	size_t hListSize = headerList.size();
        Http::Cookie theCookie;
	for(size_t idx = 0; idx < hListSize; idx++) {
	    theCookie = headerList[idx];
	    cookieLine.append(theCookie.name);
	    cookieLine.append(": ");
	    cookieLine.append(theCookie.value);
	    cookieLine.append("\r\n");
	}
        size_t listSize = cookieList.size();
	if(listSize > 0) {
	    cookieLine.append("Cookie: ");
	    for (size_t iii=0; iii < listSize; iii++) {
		theCookie = cookieList[iii];
		cookieLine.append(theCookie.name);
		cookieLine.append("=");
		cookieLine.append(theCookie.value);
		if (iii == listSize-1) {
		    cookieLine.append("\r\n");
		} else {
		    cookieLine.append(";");
		}
	    }
	}
        Log::log(logModule, Log::LOG_DEBUG,
            "BaseService::sendRequest "
            "Cookie and Headers =%s ", cookieLine.c_str());

        if (cookieLine.size() > 0) {
            status = sendChunk(conn, BodyChunk(cookieLine));
        }

        Log::log(logModule, Log::LOG_DEBUG,
            "BaseService::sendRequest "
            "Content-Length =%s.", contentLine.data.c_str());

	if (AM_SUCCESS == status) {
	    status = sendChunk(conn, contentLine);
	}

        Log::log(logModule, Log::LOG_DEBUG,
            "BaseService::sendRequest "
            "Header Suffix =%s ", headerSuffix.data.c_str());

	if (AM_SUCCESS == status) {
	    status = sendChunk(conn, headerSuffix);
	    if (AM_SUCCESS == status) {
		Log::log(logModule, Log::LOG_MAX_DEBUG,
			 "BaseService::sendRequest(): "
			 "Total chunks:  %ld.", bodyChunkList.size());
		std::size_t i = 0;
		for (i = 0; i < bodyChunkList.size(); ++i) {
		    status = sendChunk(conn, bodyChunkList[i]);
		    if (AM_SUCCESS != status) {
			Log::log(logModule, Log::LOG_ERROR,
				 "BaseService::sendRequest "
				 "Sending chunk %ld failed with error: %s",
				 i, am_status_to_string(status));
			break;
		    }
		}
		Log::log(logModule, Log::LOG_MAX_DEBUG,
			 "BaseService::sendRequest(): "
			 "Sent %ld chunks.", i);
	    }
	}
    }

    return status;
}
コード例 #8
0
void SMTPChunkingOutputStreamAdapter::flush()
{
	sendChunk(m_buffer, m_bufferSize, /* last */ true);
	m_bufferSize = 0;
}
コード例 #9
0
write_chunk(struct chunk *c)
{
	sendChunk(streamer, c);
}
コード例 #10
0
void QSocketSession::sendString(const QByteArray &s)
{
	safeSendWord((uint32_t)s.length());
	sendChunk((const uchar *)s.data(), s.length());
}