From b34e416fa9d712bb4138911a2536ee709490d96b Mon Sep 17 00:00:00 2001 From: Nguyễn Thái Ngọc Duy Date: Wed, 15 Sep 2010 18:20:16 +1000 Subject: win32: add init_winsock() All network applets must call this function before using any winsock functions. --- include/mingw.h | 1 + win32/net.c | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/include/mingw.h b/include/mingw.h index d61d87bf3..d9a2fabd1 100644 --- a/include/mingw.h +++ b/include/mingw.h @@ -346,3 +346,4 @@ void free_environ(char **env); char **env_setenv(char **env, const char *name); const char *get_busybox_exec_path(void); +void init_winsock(void); diff --git a/win32/net.c b/win32/net.c index 93e19ae5c..82c29e57c 100644 --- a/win32/net.c +++ b/win32/net.c @@ -9,3 +9,12 @@ int inet_aton(const char *cp, struct in_addr *inp) inp->S_un.S_addr = val; return 1; } + +void init_winsock(void) +{ + WSADATA wsa; + if (WSAStartup(MAKEWORD(2,2), &wsa)) + bb_error_msg_and_die("unable to initialize winsock subsystem, error %d", + WSAGetLastError()); + atexit((void(*)(void)) WSACleanup); /* may conflict with other atexit? */ +} -- cgit v1.2.3-55-g6feb