From: Dave Murphy Date: Sun, 29 Apr 2012 18:30:27 +0000 (+0100) Subject: wrap read/write socket functions on mingw X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=49bafd873992d96cd95184d45d5bd24bd657a323;p=fw%2Fstlink wrap read/write socket functions on mingw --- diff --git a/mingw/mingw.c b/mingw/mingw.c index 0cae043..493dcba 100644 --- a/mingw/mingw.c +++ b/mingw/mingw.c @@ -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) { diff --git a/mingw/mingw.h b/mingw/mingw.h index a64da57..28c7a82 100644 --- a/mingw/mingw.h +++ b/mingw/mingw.h @@ -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