diff libmpdemux/pnm.c @ 10281:54bcbf28698a

Networking support under MinGW. Patch by flo/yepyep <flodt8@yahoo.de>.
author diego
date Wed, 11 Jun 2003 16:48:09 +0000
parents 939ff11825de
children a4cba6e2dfde
line wrap: on
line diff
--- a/libmpdemux/pnm.c	Wed Jun 11 10:39:57 2003 +0000
+++ b/libmpdemux/pnm.c	Wed Jun 11 16:48:09 2003 +0000
@@ -26,9 +26,6 @@
 #include <unistd.h>
 #include <stdio.h>
 #include <assert.h>
-#include <sys/socket.h>
-//#include <netinet/in.h>
-//#include <netdb.h>
 #include <string.h>
 #include <sys/stat.h>
 #include <fcntl.h>
@@ -37,6 +34,16 @@
 #include <sys/time.h>
 #include <inttypes.h>
 
+#include "config.h"
+#ifndef HAVE_WINSOCK2
+#define closesocket close
+#include <sys/socket.h>
+//#include <netinet/in.h>
+//#include <netdb.h>
+#else
+#include <winsock2.h>
+#endif
+
 #include "pnm.h"
 //#include "libreal/rmff.h"
 
@@ -207,7 +214,11 @@
     if (n > 0)
       total += n;
     else if (n < 0) {
+#ifndef HAVE_WINSOCK2
       if ((timeout>0) && ((errno == EAGAIN) || (errno == EINPROGRESS))) {
+#else
+      if ((timeout>0) && ((errno == EAGAIN) || (WSAGetLastError() == WSAEINPROGRESS))) {
+#endif
         sleep (1); timeout--;
       } else
         return -1;
@@ -810,7 +821,7 @@
 
 void pnm_close(pnm_t *p) {
 
-  if (p->s >= 0) close(p->s);
+  if (p->s >= 0) closesocket(p->s);
   free(p->path);
   free(p);
 }