4 * Dongsheng Song <dongsheng.song@gmail.com>
5 * Brent Cook <bcook@openbsd.org>
10 #include <openssl/bio.h>
11 #include <openssl/err.h>
17 * WSAStartup loads the winsock .dll and initializes the networking
18 * stack on Windows, or simply increases the reference count.
20 static struct WSAData wsa_state
= {0};
21 WORD version_requested
= MAKEWORD(2, 2);
22 static int wsa_init_done
= 0;
24 if (WSAStartup(version_requested
, &wsa_state
) != 0) {
25 int err
= WSAGetLastError();
26 SYSerr(SYS_F_WSASTARTUP
, err
);
27 BIOerr(BIO_F_BIO_SOCK_INIT
, BIO_R_WSASTARTUP
);
36 BIO_sock_cleanup(void)
39 * We could call WSACleanup here, but it is easy to get it wrong. Since
40 * this API provides no way to even tell if it failed, there is no safe
41 * way to expose that functionality here.
43 * The cost of leaving the networking DLLs loaded may have been large
44 * during the Windows 3.1/win32s era, but it is small in modern
45 * contexts, so don't bother.
50 BIO_socket_nbio(int s
, int mode
)
53 return ioctlsocket(s
, FIONBIO
, &value
) != SOCKET_ERROR
;