Index: trunk/BNC/bncnetqueryrtp.cpp
===================================================================
--- trunk/BNC/bncnetqueryrtp.cpp	(revision 1418)
+++ trunk/BNC/bncnetqueryrtp.cpp	(revision 1419)
@@ -128,58 +128,62 @@
     }
     delete hlpSocket;
-    
-    QByteArray clientPort = QString("%1").arg(clientPortInt).toAscii();
-    delete _udpSocket;
-    _udpSocket = new QUdpSocket();
-    _udpSocket->bind(clientPortInt);
-    connect(_udpSocket, SIGNAL(readyRead()), _eventLoop, SLOT(quit()));
-    
-    QByteArray reqStr;
-    reqStr = "SETUP " + urlLoc.toEncoded() + " RTSP/1.0\r\n"
-           + "Cseq: 1\r\n"
-           + "Ntrip-Version: Ntrip/2.0\r\n"
-           + "Ntrip-Component: Ntripclient\r\n"
-           + "User-Agent: NTRIP BNC/" BNCVERSION "\r\n"
-           + "Transport: RTP/GNSS;unicast;client_port=" + clientPort + "\r\n"
-           + userAndPwd 
-           + "\r\n";
-    _socket->write(reqStr, reqStr.length());
-    
-    // Read Server Answer 1
-    // --------------------
-    if (_socket->waitForBytesWritten(timeOut)) {
-      if (_socket->waitForReadyRead(timeOut)) {
-        QTextStream in(_socket);
-        QByteArray session;
-        QString line = in.readLine();
-        while (!line.isEmpty()) {
-          if (line.indexOf("Session:") == 0) {
-            session = line.mid(9).toAscii();
-            break;
+
+    // Setup the RTSP Connection
+    // -------------------------
+    if (clientPortInt) {    
+      QByteArray clientPort = QString("%1").arg(clientPortInt).toAscii();
+      delete _udpSocket;
+      _udpSocket = new QUdpSocket();
+      _udpSocket->bind(clientPortInt);
+      connect(_udpSocket, SIGNAL(readyRead()), _eventLoop, SLOT(quit()));
+      
+      QByteArray reqStr;
+      reqStr = "SETUP " + urlLoc.toEncoded() + " RTSP/1.0\r\n"
+             + "Cseq: 1\r\n"
+             + "Ntrip-Version: Ntrip/2.0\r\n"
+             + "Ntrip-Component: Ntripclient\r\n"
+             + "User-Agent: NTRIP BNC/" BNCVERSION "\r\n"
+             + "Transport: RTP/GNSS;unicast;client_port=" + clientPort + "\r\n"
+             + userAndPwd 
+             + "\r\n";
+      _socket->write(reqStr, reqStr.length());
+      
+      // Read Server Answer 1
+      // --------------------
+      if (_socket->waitForBytesWritten(timeOut)) {
+        if (_socket->waitForReadyRead(timeOut)) {
+          QTextStream in(_socket);
+          QByteArray session;
+          QString line = in.readLine();
+          while (!line.isEmpty()) {
+            if (line.indexOf("Session:") == 0) {
+              session = line.mid(9).toAscii();
+              break;
+            }
+            line = in.readLine();
           }
-          line = in.readLine();
-        }
-
-        // Send Request 2
-        // --------------
-        if (!session.isEmpty()) { 
-          reqStr = "PLAY " + urlLoc.toEncoded() + " RTSP/1.0\r\n"
-                 + "Cseq: 2\r\n"
-                 + "Session: " + session + "\r\n"
-                 + "\r\n";
-          _socket->write(reqStr, reqStr.length());
-
-          // Read Server Answer 2
-          // --------------------
-          if (_socket->waitForBytesWritten(timeOut)) {
-            if (_socket->waitForReadyRead(timeOut)) {
-              QTextStream in(_socket);
-              line = in.readLine();
-              while (!line.isEmpty()) {
-                if (line.indexOf("200 OK") != -1) {
-                  emit newMessage("UDP connection established", true);
-                  return;
+      
+          // Send Request 2
+          // --------------
+          if (!session.isEmpty()) { 
+            reqStr = "PLAY " + urlLoc.toEncoded() + " RTSP/1.0\r\n"
+                   + "Cseq: 2\r\n"
+                   + "Session: " + session + "\r\n"
+                   + "\r\n";
+            _socket->write(reqStr, reqStr.length());
+      
+            // Read Server Answer 2
+            // --------------------
+            if (_socket->waitForBytesWritten(timeOut)) {
+              if (_socket->waitForReadyRead(timeOut)) {
+                QTextStream in(_socket);
+                line = in.readLine();
+                while (!line.isEmpty()) {
+                  if (line.indexOf("200 OK") != -1) {
+                    emit newMessage("UDP connection established", true);
+                    return;
+                  }
+                  line = in.readLine();
                 }
-                line = in.readLine();
               }
             }
