- Timestamp:
- Mar 4, 2009, 9:11:06 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/bncnetqueryudp.cpp
r1718 r1719 28 28 //////////////////////////////////////////////////////////////////////////// 29 29 bncNetQueryUdp::bncNetQueryUdp() { 30 _port = 0; 30 31 _udpSocket = 0; 31 32 _eventLoop = new QEventLoop(this); … … 83 84 _status = running; 84 85 86 // Default scheme and path 87 // ----------------------- 88 _url = url; 89 if (_url.scheme().isEmpty()) { 90 _url.setScheme("http"); 91 } 92 if (_url.path().isEmpty()) { 93 _url.setPath("/"); 94 } 95 96 _port = _url.port(); 97 85 98 delete _udpSocket; 86 99 _udpSocket = new QUdpSocket(); 87 _udpSocket->bind(0);88 100 connect(_udpSocket, SIGNAL(readyRead()), _eventLoop, SLOT(quit())); 89 QByteArray clientPort = QString("%1").arg(_udpSocket->localPort()).toAscii();90 91 // Send initial RTP packet for firewall handling92 // ---------------------------------------------93 char rtpbuffer[12];94 rtpbuffer[0] = (2<<6);95 rtpbuffer[1] = 96;96 rtpbuffer[2] = 0;97 rtpbuffer[3] = 0;98 rtpbuffer[4] = 0;99 rtpbuffer[5] = 0;100 rtpbuffer[6] = 0;101 rtpbuffer[7] = 0;102 rtpbuffer[8] = 0;103 rtpbuffer[9] = 0;104 rtpbuffer[10] = 0;105 rtpbuffer[11] = 0;106 101 107 102 QHostInfo hInfo = QHostInfo::fromName(url.host()); 108 103 109 QHostAddress address;110 104 if (!hInfo.addresses().isEmpty()) { 111 address = hInfo.addresses().first(); 112 _udpSocket->writeDatagram(rtpbuffer, 12, address, url.port()); 105 106 _address = hInfo.addresses().first(); 107 108 // Send initial RTP packet for firewall handling 109 // --------------------------------------------- 110 char rtpbuffer[12]; 111 rtpbuffer[0] = (2<<6); 112 rtpbuffer[1] = 96; 113 rtpbuffer[2] = 0; 114 rtpbuffer[3] = 0; 115 rtpbuffer[4] = 0; 116 rtpbuffer[5] = 0; 117 rtpbuffer[6] = 0; 118 rtpbuffer[7] = 0; 119 rtpbuffer[8] = 0; 120 rtpbuffer[9] = 0; 121 rtpbuffer[10] = 0; 122 rtpbuffer[11] = 0; 123 124 _udpSocket->writeDatagram(rtpbuffer, 12, _address, _port); 125 126 // Send Request 127 // ------------ 128 QString uName = QUrl::fromPercentEncoding(_url.userName().toAscii()); 129 QString passW = QUrl::fromPercentEncoding(_url.password().toAscii()); 130 QByteArray userAndPwd; 131 132 if(!uName.isEmpty() || !passW.isEmpty()) { 133 userAndPwd = "Authorization: Basic " + (uName.toAscii() + ":" + 134 passW.toAscii()).toBase64() + "\r\n"; 135 } 136 137 QByteArray reqStr = "GET " + _url.path().toAscii() + " HTTP/1.0\r\n" 138 + "User-Agent: NTRIP BNC/" BNCVERSION "\r\n" 139 + userAndPwd + "\r\n"; 140 141 // NMEA string to handle VRS stream 142 // -------------------------------- 143 if (!gga.isEmpty()) { 144 reqStr += gga + "\r\n"; 145 } 146 113 147 } 114 115 148 } 116 149
Note:
See TracChangeset
for help on using the changeset viewer.