aboutsummaryrefslogtreecommitdiff
path: root/libbb/mingw.c
diff options
context:
space:
mode:
Diffstat (limited to 'libbb/mingw.c')
-rw-r--r--libbb/mingw.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/libbb/mingw.c b/libbb/mingw.c
index 4b267e2ba..1293dc7eb 100644
--- a/libbb/mingw.c
+++ b/libbb/mingw.c
@@ -997,16 +997,24 @@ char **env_setenv(char **env, const char *name)
997 return env; 997 return env;
998} 998}
999 999
1000void winsock_init()
1001{
1002 static int init = 0;
1003 if (!init) {
1004 WSADATA wsa;
1005 if (WSAStartup(MAKEWORD(2,2), &wsa))
1006 die("unable to initialize winsock subsystem, error %d",
1007 WSAGetLastError());
1008 atexit((void(*)(void)) WSACleanup);
1009 init = 1;
1010 }
1011}
1012
1000/* this is the first function to call into WS_32; initialize it */ 1013/* this is the first function to call into WS_32; initialize it */
1001#undef gethostbyname 1014#undef gethostbyname
1002struct hostent *mingw_gethostbyname(const char *host) 1015struct hostent *mingw_gethostbyname(const char *host)
1003{ 1016{
1004 WSADATA wsa; 1017 winsock_init();
1005
1006 if (WSAStartup(MAKEWORD(2,2), &wsa))
1007 die("unable to initialize winsock subsystem, error %d",
1008 WSAGetLastError());
1009 atexit((void(*)(void)) WSACleanup);
1010 return gethostbyname(host); 1018 return gethostbyname(host);
1011} 1019}
1012 1020