//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// $Id$
# include <config.h>
#endif
+#include <cstring>
+
#include <simgear/debug/logstream.hxx>
#include <simgear/io/lowlevel.hxx> // endian tests
+#include <simgear/io/sg_netBuffer.hxx>
#include <Main/fg_props.hxx>
#include <Network/native_ctrls.hxx>
#include "ExternalNet.hxx"
+class HTTPClient : public simgear::NetBufferChannel
+{
+
+ bool done;
+ SGTimeStamp start;
+ simgear::NetChannelPoller poller;
+public:
+
+ HTTPClient ( const char* host, int port, const char* path ) :
+ done( false )
+ {
+ open ();
+ connect (host, port);
+
+ char buffer[256];
+ ::snprintf (buffer, 256, "GET %s HTTP/1.0\r\n\r\n", path );
+ bufferSend(buffer, strlen(buffer) ) ;
+
+ poller.addChannel(this);
+ start.stamp();
+ }
+
+ virtual void handleBufferRead (simgear::NetBuffer& buffer)
+ {
+ const char* s = buffer.getData();
+ while (*s)
+ fputc(*s++,stdout);
+
+ printf("done\n");
+ buffer.remove();
+ printf("after buffer.remove()\n");
+ done = true;
+ }
+
+ bool isDone() const { return done; }
+ bool isDone( long usec ) const {
+ if ( start + SGTimeStamp::fromUSec(usec) < SGTimeStamp::now() ) {
+ return true;
+ } else {
+ return done;
+ }
+ }
+
+ void poll(int timeout)
+ {
+ poller.poll(timeout);
+ }
+};
+
FGExternalNet::FGExternalNet( double dt, string host, int dop, int dip, int cp )
{
// set_delta_t( dt );