示例#1
0
void ServerSktUdp::send(void* cookie, const QByteArray& bin)
{
	Conn* conn = (Conn*)cookie;

	const char*  src = bin.constData(); 
	qint64 srcLen = bin.length();

	qint64 writeLen = 0;
	qint64 ioLen = m_server.writeDatagram(src, srcLen, conn->addr, conn->port);

	while (ioLen > 0)
	{
		writeLen += ioLen;

		ioLen = (writeLen >= srcLen) ? 0 :
				m_server.writeDatagram(src+writeLen, srcLen-writeLen, conn->addr, conn->port);
	}

	if (writeLen != srcLen)
	{
		show(QString("failed to send data to %1:%2 [%3]")
			.arg(conn->addr.toString()).arg(conn->port).arg(writeLen));
		return;
	}

	recordSend(writeLen);
	dump(src, srcLen, true, conn->key);
}
示例#2
0
void ClientSktUdp::send(const QByteArray& bin)
{
    const char *  src = bin.constData(); 
    qint64 srcLen = bin.length();

    qint64 writeLen = 0;
    qint64 ioLen = m_socket.write(src, srcLen);

    while (ioLen > 0)
    {
        writeLen += ioLen;
        ioLen = (writeLen >= srcLen) ? 0 :
                m_socket.write(src+writeLen, srcLen-writeLen);
    }

    if (writeLen != srcLen)
    {
        show(QString("failed to send data to %1:%2 [%3]")
            .arg(addr().toString()).arg(port()).arg(writeLen));
        return;
    }

    recordSend(writeLen);
    dump(src, srcLen, true);
}
示例#3
0
void ServerSktTcp::send(void* cookie, const QByteArray& bin)
{
	Conn* conn = (Conn*)cookie;

	const char *  src = bin.constData(); 
	qint64 srcLen = bin.length();

	qint64 writeLen = 0;
	qint64 ioLen = conn->client->write(src, srcLen);

	while (ioLen > 0)
	{
		writeLen += ioLen;
		ioLen = conn->client->write(src+writeLen, srcLen-writeLen);
	}

	if (writeLen != srcLen)
	{
		show(QString("failed to send data to %1:%2 [%3]")
			.arg(addr().toString()).arg(port()).arg(writeLen));
		return;
	}

	recordSend(writeLen);
	dump(src, srcLen, true, conn->key);
}
示例#4
0
文件: Endpoint.cpp 项目: ey6es/hifi
Endpoint::Endpoint(const SharedNodePointer& node, PacketRecord* baselineSendRecord, PacketRecord* baselineReceiveRecord) :
    _node(node),
    _sequencer(byteArrayWithPopulatedHeader(PacketTypeMetavoxelData), this) {
    
    connect(&_sequencer, SIGNAL(readyToWrite(const QByteArray&)), SLOT(sendDatagram(const QByteArray&)));
    connect(&_sequencer, SIGNAL(readyToRead(Bitstream&)), SLOT(readMessage(Bitstream&)));
    connect(&_sequencer, SIGNAL(sendRecorded()), SLOT(recordSend()));
    connect(&_sequencer, SIGNAL(receiveRecorded()), SLOT(recordReceive()));
    connect(&_sequencer, SIGNAL(sendAcknowledged(int)), SLOT(clearSendRecordsBefore(int)));
    connect(&_sequencer, SIGNAL(receiveAcknowledged(int)), SLOT(clearReceiveRecordsBefore(int)));
    
    // insert the baseline send and receive records
    _sendRecords.append(baselineSendRecord);
    _receiveRecords.append(baselineReceiveRecord);
}