#include <cstdio>
#include <cstring>
+#include <signal.h>
-#include <unistd.h> // for STDOUT_FILENO
#include <iostream>
#include <boost/foreach.hpp>
+
#include <simgear/io/sg_file.hxx>
#include <simgear/io/HTTPClient.hxx>
#include <simgear/io/HTTPRequest.hxx>
#include <simgear/io/sg_netChannel.hxx>
#include <simgear/misc/strutils.hxx>
+#include <simgear/timing/timestamp.hxx>
using namespace simgear;
using std::cout;
int main(int argc, char* argv[])
{
HTTP::Client cl;
- SGFile* outFile;
+ SGFile* outFile = 0;
string proxy, proxyAuth;
string_list headers;
string url;
if (colonPos >= 0) {
proxyHost = proxy.substr(0, colonPos);
proxyPort = strutils::to_int(proxy.substr(colonPos + 1));
- cout << proxyHost << " " << proxyPort << endl;
}
cl.setProxy(proxyHost, proxyPort, proxyAuth);
}
+#ifndef WIN32
+ signal(SIGPIPE, SIG_IGN);
+#endif
+
if (!outFile) {
- outFile = new SGFile(STDOUT_FILENO);
+ outFile = new SGFile(fileno(stdout));
}
if (url.empty()) {
cl.makeRequest(req);
while (!req->complete()) {
- NetChannel::poll(100);
+ cl.update();
+ SGTimeStamp::sleepForMSec(100);
}
-
+
if (req->responseCode() != 200) {
cerr << "got response:" << req->responseCode() << endl;
cerr << "\treason:" << req->responseReason() << endl;