(main) [_WIN32]: Don't call WSAStartup() until after option

processing, so that we can version and help even when it fails.  Fix
program exit status on failure.
This commit is contained in:
Markus Armbruster 2007-11-17 08:07:30 +00:00
parent 0414ee66a2
commit d01aa85577

View file

@ -125,12 +125,6 @@ main(int argc, char **argv)
* after each prompt is required.
*/
setvbuf(stdout, NULL, _IOLBF, 4096);
wVersionRequested = MAKEWORD(2, 0);
err = WSAStartup(wVersionRequested, &WsaData);
if (err != 0) {
printf("WSAStartup Failed, error code %d\n", err);
return FALSE;
}
#else
FD_ZERO(&mask);
FD_ZERO(&savemask);
@ -204,6 +198,15 @@ main(int argc, char **argv)
exit(1);
}
#ifdef _WIN32
wVersionRequested = MAKEWORD(2, 0);
err = WSAStartup(wVersionRequested, &WsaData);
if (err != 0) {
printf("WSAStartup Failed, error code %d\n", err);
exit(1);
}
#endif
sock = tcp_connect(host, port);
if (!login(sock, uname, country, passwd, send_kill, utf8)) {