wrap read/write socket functions on mingw
authorDave Murphy <davem@devkitpro.org>
Sun, 29 Apr 2012 18:30:27 +0000 (19:30 +0100)
committerDave Murphy <davem@devkitpro.org>
Sun, 29 Apr 2012 18:30:27 +0000 (19:30 +0100)
mingw/mingw.c
mingw/mingw.h

index 0cae043c11a3610b525a9519ab7cb687f81443f2..493dcbaa274aa62e3097c1a0242ef23416149240 100644 (file)
@@ -171,7 +171,7 @@ int win32_close_socket(SOCKET fd) {
 }
 
 
-int win32_write_socket(SOCKET fd, void *buf, int n)
+ssize_t win32_write_socket(SOCKET fd, void *buf, int n)
 {
     int rc = send(fd, buf, n, 0);
     if(rc == SOCKET_ERROR) {
@@ -180,7 +180,7 @@ int win32_write_socket(SOCKET fd, void *buf, int n)
     return rc;
 }
 
-int win32_read_socket(SOCKET fd, void *buf, int n)
+ssize_t win32_read_socket(SOCKET fd, void *buf, int n)
 {
     int rc = recv(fd, buf, n, 0);
     if(rc == SOCKET_ERROR) {
index a64da570f1a2d012614c224b3d846ab58114c705..28c7a82e0278be7f628bf6a96f5150fb639b545f 100644 (file)
@@ -39,10 +39,12 @@ struct pollfd {
  * outside of this file "shouldn't" have to worry about winsock specific error
  * handling.
  */
-#define socket(x, y, z)      win32_socket(x, y, z)
-#define connect(x, y, z)     win32_connect(x, y, z)
-#define accept(x, y, z)      win32_accept(x, y, z)
-#define shutdown(x, y)       win32_shutdown(x, y)
+#define socket(x, y, z)                win32_socket(x, y, z)
+#define connect(x, y, z)       win32_connect(x, y, z)
+#define accept(x, y, z)                win32_accept(x, y, z)
+#define shutdown(x, y)         win32_shutdown(x, y)
+#define read(x, y, z)                  win32_read_socket(x, y, z)
+#define write(x, y, z)                 win32_write_socket(x, y, z)
 
 /* Winsock uses int instead of the usual socklen_t */
 typedef int socklen_t;
@@ -59,4 +61,8 @@ int     win32_shutdown(SOCKET, int);
 char *win32_strtok_r(char *s, const char *delim, char **lasts);
 char *win32_strsep(char **stringp, const char *delim);
 
+ssize_t win32_read_socket(SOCKET fd, void *buf, int n);
+ssize_t win32_write_socket(SOCKET fd, void *buf, int n);
+
+
 #endif