]> git.mxchange.org Git - flightgear.git/commitdiff
Allow for a user specified timeout when waiting for a response from the
authorcurt <curt>
Tue, 1 Oct 2002 16:44:38 +0000 (16:44 +0000)
committercurt <curt>
Tue, 1 Oct 2002 16:44:38 +0000 (16:44 +0000)
remote fdm command server (http server.)

src/FDM/ExternalNet/ExternalNet.cxx
src/FDM/ExternalNet/ExternalNet.hxx

index e5e450908f2e38699e720a563fd3e7d1267bb269..eae848793bc55928ef6589a528baaf6d2f22241e 100644 (file)
@@ -387,29 +387,29 @@ void FGExternalNet::init() {
     HTTPClient *http;
     sprintf( cmd, "/longitude-deg?value=%.8f", lon );
     http = new HTTPClient( fdm_host.c_str(), cmd_port, cmd );
-    while ( !http->isDone() ) http->poll(0);
+    while ( !http->isDone(1000000) ) http->poll(0);
     delete http;
 
     sprintf( cmd, "/latitude-deg?value=%.8f", lat );
     http = new HTTPClient( fdm_host.c_str(), cmd_port, cmd );
-    while ( !http->isDone() ) http->poll(0);
+    while ( !http->isDone(1000000) ) http->poll(0);
     delete http;
 
     sprintf( cmd, "/ground-m?value=%.8f", ground );
     http = new HTTPClient( fdm_host.c_str(), cmd_port, cmd );
-    while ( !http->isDone() ) http->poll(0);
+    while ( !http->isDone(1000000) ) http->poll(0);
     delete http;
 
     sprintf( cmd, "/heading-deg?value=%.8f", heading );
     http = new HTTPClient( fdm_host.c_str(), cmd_port, cmd );
-    while ( !http->isDone() ) http->poll(0);
+    while ( !http->isDone(1000000) ) http->poll(0);
     delete http;
 
     SG_LOG( SG_IO, SG_INFO, "before sending reset command." );
 
     sprintf( cmd, "/reset?value=ground" );
     http = new HTTPClient( fdm_host.c_str(), cmd_port, cmd );
-    while ( !http->isDone() ) http->poll(0);
+    while ( !http->isDone(1000000) ) http->poll(0);
     delete http;
 
     SG_LOG( SG_IO, SG_INFO, "Remote FDM init() finished." );
index 3943e1a8913a9012a4327d1c6877efcaf14e5fb9..7e36856a2a0408dc4a63c975262065f7ff94da84 100644 (file)
@@ -26,6 +26,8 @@
 #include <plib/netBuffer.h>
 #include <plib/netSocket.h>
 
+#include <simgear/timing/timestamp.hxx> // fine grained timing measurements
+
 #include <Network/net_ctrls.hxx>
 #include <Network/net_fdm.hxx>
 
@@ -36,6 +38,7 @@ class HTTPClient : public netBufferChannel
 {
 
     bool done;
+    SGTimeStamp start;
 
 public:
 
@@ -47,6 +50,8 @@ public:
 
        cchar* s = netFormat ( "GET %s HTTP/1.0\r\n\r\n", path );
        bufferSend( s, strlen(s) ) ;
+
+        start.stamp();
     }
 
     virtual void handleBufferRead (netBuffer& buffer)
@@ -62,6 +67,15 @@ public:
     }
 
     bool isDone() const { return done; }
+    bool isDone( long usec ) const { 
+        SGTimeStamp now;
+        now.stamp();
+        if ( (now - start) > usec ) {
+            return true;
+        } else {
+            return done;
+        }
+    }
 };