Hi, For a long, LONG time the small utility program metar.exe has failed to work in windows...
It turns out WSAStartup() is NOT called, thus the HTTP request always fails... Applied this simple patch below, and all is well ;=)) Hope this can get into fg git, and I hope pushed to Release/2.8.0 as well, and thus get into the next fgrun release 2.8 windows install... Regards, Geoff. <metar.patch> diff --git a/src/Main/metar_main.cxx b/src/Main/metar_main.cxx index 7b904d3..833ac2e 100644 --- a/src/Main/metar_main.cxx +++ b/src/Main/metar_main.cxx @@ -533,6 +533,45 @@ void usage() ); } +static bool doneNetInit = false; +static void netExit(void) +{ + if (doneNetInit) + { +#ifdef WIN32 + /* Clean up windows networking */ + if ( WSACleanup() == SOCKET_ERROR ) { + if ( WSAGetLastError() == WSAEINPROGRESS ) { + WSACancelBlockingCall(); + WSACleanup(); + } + } +#endif // WIN32 + doneNetInit = false; + } +} + +static int netInit(void) +{ + int iret = 0; + if (!doneNetInit) + { +#ifdef WIN32 + /* Start up the windows networking */ + WORD version_wanted = MAKEWORD(1,1); + WSADATA wsaData; + if ( WSAStartup(version_wanted, &wsaData) != 0 ) { + printf("Couldn't initialize Winsock 1.1\n"); + iret = 1; + } +#endif // WIN32 + doneNetInit = true; + atexit( netExit ); + } + return iret; +} + + int main(int argc, char *argv[]) { bool report = true; @@ -544,6 +583,8 @@ int main(int argc, char *argv[]) return 0; } + if (netInit()) + return 1; string proxy_host, proxy_port; getproxy(proxy_host, proxy_port); @@ -574,6 +615,9 @@ int main(int argc, char *argv[]) } try { + if (verbose) + printf("Getting metar for [%s]\n",argv[i]); + MetarRequest* mr = new MetarRequest(argv[i]); HTTP::Request_ptr own(mr); http.makeRequest(mr); </metar.patch> ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Flightgear-devel mailing list Flightgear-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/flightgear-devel