Parcourir la source

windows 8 changed the API for getsockopt

Julius Pfrommer il y a 9 ans
Parent
commit
43d0de0e88
1 fichiers modifiés avec 6 ajouts et 1 suppressions
  1. 6 1
      examples/networklayer_tcp.c

+ 6 - 1
examples/networklayer_tcp.c

@@ -92,9 +92,14 @@ socket_recv(UA_Connection *connection, UA_ByteString *response, UA_UInt32 timeou
 
     if(timeout > 0) {
         /* currently, only the client uses timeouts */
+#ifndef _WIN32
         int timeout_usec = timeout * 1000;
         struct timeval tmptv = {timeout_usec / 1000000, timeout_usec % 1000000};
-        int ret = setsockopt(connection->sockfd, SOL_SOCKET, SO_RCVTIMEO, (char *)&tmptv, sizeof(struct timeval));
+        int ret = setsockopt(connection->sockfd, SOL_SOCKET, SO_RCVTIMEO, (const char *)&tmptv, sizeof(struct timeval));
+#else
+        DWORD timeout_dw = timeout;
+        int ret = setsockopt(connection->sockfd, SOL_SOCKET, SO_RCVTIMEO, (const char*)&timeout_dw, sizeof(DWORD));
+#endif
         if(0 != ret) {
             UA_ByteString_deleteMembers(response);
             socket_close(connection);