void Widget::readMessage()
{
int count = 0;
unsigned char* hex; /* 밥법 1 */
char* pData; /* 방법 2 */
if(tcpSocket->bytesAvailable() >= 0)
{
QByteArray readData = tcpSocket->readAll();
ui->textEdit->append(readData);
/* change to CHAR */
count = readData.size();
hex =new unsigned char[count];
memcpy(hex,readData.constData(),count);
pData = readData.data();
for(int i = 0; i < readData.size(); i++)
{
unsigned int j = readData.at(i);
qDebug() << QString("readData.at 0x%1").arg((int)j, 0, 16);
qDebug() << QString("pData 0x%1").arg((int)pData[i], 0, 16);
qDebug() << QString("hex 0x%1").arg((int)hex[i], 0, 16);
ui->textEdit->append(QString("0x%1").arg((int)j, 0, 16));
}
ui->textEdit->append(QString(readData.toHex(':')));
}
// disconnect from TCP server
tcpSocket->disconnectFromHost();
ui->textEdit->append(QString("Disconnect from Host"));
}
댓글 없음:
댓글 쓰기