]> git.meshlink.io Git - catta/blobdiff - src/compat/windows/wincompat.h
readpipe/writepite/closepipe for fake pipes on Windows
[catta] / src / compat / windows / wincompat.h
index c736f75f938dc03868c75accbad1354239e21d37..f611e33e581534346e81022dafb3f83759c87084 100644 (file)
 #include <mswsock.h>
 
 
+// wrappers around WSAStartup/WSACleanup to avoid clutter
+void winsock_init(void);
+void winsock_exit(void);
+
+
+// the equivalent of strerror(errno) for Windows sockets
+char *errnostrsocket(void);
+
+
 // Winsock doesn't have recvmsg/sendmsg but offers the same functionality
 // with WSARecvMsg/WSASendMsg, so we implement the former in terms of the
 // latter.
@@ -90,6 +99,11 @@ int ioctl(int d, unsigned long request, int *p);
 // something to give to WSAPoll, so we fake it with a local TCP socket. (ugh)
 int pipe(int pipefd[2]);
 
+// pipe(socket)-specific read/write/close equivalents
+#define closepipe closesocket
+#define writepipe(s,buf,len) send(s, buf, len, 0)
+#define readpipe(s,buf,len) recv(s, buf, len, 0)
+
 
 // Windows logically doesn't have uname, so we supply a replacement.