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); }
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); }
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); }
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); }