Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

wrap read/write socket functions on mingw

  • Loading branch information...
commit 49bafd873992d96cd95184d45d5bd24bd657a323 1 parent c5b021c
@WinterMute authored
Showing with 12 additions and 6 deletions.
  1. +2 −2 mingw/mingw.c
  2. +10 −4 mingw/mingw.h
View
4 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) {
View
14 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
Please sign in to comment.
Something went wrong with that request. Please try again.