Help form a QByteArray to send it to stun.ekiga.net server in a UDP datagram. The application, written by me on the basis of the kindly provided assistance to me, sends only empty requests and not identified by Wireshark as requests under the STUN protocol, alas .. The package should look like this: right-request-to-stun http: // img-host.org.ua/images/1vlv.png And sent by my application looks like this: my-wrong-request http://img-host.org.ua/images/2hl.png And this happens even when I used. I guess I used it incorrectly. Therefore, I refused functions like qToBigEndian and qFromBigEndian - and began simply to add the necessary fields, having first converted them to a binary form. This is how my code finally began to look like, again, idle:
UdpToStun::UdpToStun(QObject *parent) : QObject(parent) { port = 3478; sock = new QUdpSocket(); lstd = new QUdpSocket(); connect(lstd, SIGNAL(readyRead()), SLOT(read())); lstd->bind(QHostAddress::Any, port); // хочу и ответ же получить, вот и открываю слушающий сокет QByteArray ba; ba.append(0x1); // Тип запроса: 1 - binding request ba.append(0x0); // Тип сообщения: 0 - reguest ba.append(100001000100101010010001000010); // Это бинарное представление magic cookie, они у STUN'а по стандарту всегда равны 0x2112A442 sock->writeDatagram(ba, QHostAddress("217.10.68.152"), port); }
QByteArraydo you write a huge integer instead of0x2112A442? - alexis031182