diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2010-09-15 18:20:16 +1000 |
---|---|---|
committer | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2010-09-20 17:51:16 +1000 |
commit | b34e416fa9d712bb4138911a2536ee709490d96b (patch) | |
tree | 82e5fc942fd6ace12a0f1f851b987ca3f61576e8 | |
parent | 7dc41624d037b85b8498c3a679415a74e00b90cf (diff) | |
download | busybox-w32-b34e416fa9d712bb4138911a2536ee709490d96b.tar.gz busybox-w32-b34e416fa9d712bb4138911a2536ee709490d96b.tar.bz2 busybox-w32-b34e416fa9d712bb4138911a2536ee709490d96b.zip |
win32: add init_winsock()
All network applets must call this function before using any winsock
functions.
-rw-r--r-- | include/mingw.h | 1 | ||||
-rw-r--r-- | win32/net.c | 9 |
2 files changed, 10 insertions, 0 deletions
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); | |||
346 | char **env_setenv(char **env, const char *name); | 346 | char **env_setenv(char **env, const char *name); |
347 | 347 | ||
348 | const char *get_busybox_exec_path(void); | 348 | const char *get_busybox_exec_path(void); |
349 | 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) | |||
9 | inp->S_un.S_addr = val; | 9 | inp->S_un.S_addr = val; |
10 | return 1; | 10 | return 1; |
11 | } | 11 | } |
12 | |||
13 | void init_winsock(void) | ||
14 | { | ||
15 | WSADATA wsa; | ||
16 | if (WSAStartup(MAKEWORD(2,2), &wsa)) | ||
17 | bb_error_msg_and_die("unable to initialize winsock subsystem, error %d", | ||
18 | WSAGetLastError()); | ||
19 | atexit((void(*)(void)) WSACleanup); /* may conflict with other atexit? */ | ||
20 | } | ||