win32sockets.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Note: This is only required if you use curl 7.8 or lower, later
  3. * versions provide an option to curl_global_init() that does the
  4. * win32 initialization for you.
  5. */
  6. /*
  7. * These are example functions doing socket init that Windows
  8. * require. If you don't use windows, you can safely ignore this crap.
  9. */
  10. #include <windows.h>
  11. void win32_cleanup(void)
  12. {
  13. WSACleanup();
  14. }
  15. int win32_init(void)
  16. {
  17. WORD wVersionRequested;
  18. WSADATA wsaData;
  19. int err;
  20. wVersionRequested = MAKEWORD(1, 1);
  21. err = WSAStartup(wVersionRequested, &wsaData);
  22. if (err != 0)
  23. /* Tell the user that we couldn't find a useable */
  24. /* winsock.dll. */
  25. return 1;
  26. /* Confirm that the Windows Sockets DLL supports 1.1.*/
  27. /* Note that if the DLL supports versions greater */
  28. /* than 1.1 in addition to 1.1, it will still return */
  29. /* 1.1 in wVersion since that is the version we */
  30. /* requested. */
  31. if ( LOBYTE( wsaData.wVersion ) != 1 ||
  32. HIBYTE( wsaData.wVersion ) != 1 ) {
  33. /* Tell the user that we couldn't find a useable */
  34. /* winsock.dll. */
  35. WSACleanup();
  36. return 1;
  37. }
  38. return 0; /* 0 is ok */
  39. }