networkhandler.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*******************************************************************************
  2. * Copyright (c) 2009, Rockwell Automation, Inc.
  3. * All rights reserved.
  4. *
  5. ******************************************************************************/
  6. #include <string.h>
  7. #include <stdlib.h>
  8. #include <winsock2.h>
  9. #include <windows.h>
  10. #include <Ws2tcpip.h>
  11. #include "networkhandler.h"
  12. #include "generic_networkhandler.h"
  13. MicroSeconds getMicroSeconds() {
  14. LARGE_INTEGER performance_counter;
  15. LARGE_INTEGER performance_frequency;
  16. QueryPerformanceCounter(&performance_counter);
  17. QueryPerformanceFrequency(&performance_frequency);
  18. return (MicroSeconds) (performance_counter.QuadPart * 1000000LL
  19. / performance_frequency.QuadPart);
  20. }
  21. MilliSeconds GetMilliSeconds(void) {
  22. return (MilliSeconds) (getMicroSeconds() / 1000ULL);
  23. }
  24. EipStatus NetworkHandlerInitializePlatform(void) {
  25. WSADATA wsaData;
  26. const WORD wVersionRequested = MAKEWORD(2, 2);
  27. WSAStartup(wVersionRequested, &wsaData);
  28. return kEipStatusOk;
  29. }
  30. void CloseSocketPlatform(int socket_handle) {
  31. closesocket(socket_handle);
  32. }
  33. int SetSocketToNonBlocking(int socket_handle) {
  34. u_long iMode = 1;
  35. return ioctlsocket(socket_handle, FIONBIO, &iMode);
  36. }
  37. int SetQosOnSocket(const int socket,
  38. CipUsint qos_value) {
  39. return 0; // Dummy implementation, until a working one is viable
  40. }