瀏覽代碼

make windows happy

ithewei 5 年之前
父節點
當前提交
75c30749fd
共有 3 個文件被更改,包括 14 次插入0 次删除
  1. 3 0
      event/hloop.c
  2. 6 0
      unittest/ping_test.c
  3. 5 0
      unittest/socketpair_test.c

+ 3 - 0
event/hloop.c

@@ -575,6 +575,9 @@ static void fill_io_type(hio_t* io) {
         default: io->io_type = HIO_TYPE_FILE;   break;
         }
     }
+    else {
+        io->io_type = HIO_TYPE_TCP;
+    }
 }
 
 static void hio_socket_init(hio_t* io) {

+ 6 - 0
unittest/ping_test.c

@@ -1,5 +1,6 @@
 #include <stdio.h>
 #include "icmp.h"
+#include "hplatform.h"
 
 int main(int argc, char* argv[]) {
     if (argc < 2) {
@@ -7,6 +8,11 @@ int main(int argc, char* argv[]) {
         return -10;
     }
 
+#ifdef OS_WIN
+    WSADATA wsadata;
+    WSAStartup(MAKEWORD(2,2), &wsadata);
+#endif
+
     char* host = argv[1];
     int ping_cnt = 4;
     int ok_cnt = ping(host, ping_cnt);

+ 5 - 0
unittest/socketpair_test.c

@@ -3,6 +3,11 @@
 #include "hsocket.h"
 
 int main(int argc, char* argv[]) {
+#ifdef OS_WIN
+    WSADATA wsadata;
+    WSAStartup(MAKEWORD(2,2), &wsadata);
+#endif
+
     int sockfds[2];
     if (Socketpair(AF_INET, SOCK_STREAM, 0, sockfds) != 0) {
         printf("socketpair failed!\n");