From 19d9fcbda8637099854f2d8147b402b4420d19f5 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Thu, 5 Jan 2006 22:51:37 +0000 Subject: Port to Windows. This is mostly glue layers for the poor POSIX support on Windows. A few notes * Only sockets behave somewhat like file descriptors in UNIX. * There are no fixed paths. Closes thing is environment variables that point to system directories. We also figure out where the binary/dll is located and use that as configuration directory. git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/ossman@418 fefdeb5f-60dc-0310-8127-8f9354f1896f --- polyp/iochannel.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'polyp/iochannel.c') diff --git a/polyp/iochannel.c b/polyp/iochannel.c index 0e7e8db8..08a4e362 100644 --- a/polyp/iochannel.c +++ b/polyp/iochannel.c @@ -28,6 +28,10 @@ #include #include +#ifdef HAVE_WINSOCK2_H +#include +#endif + #include "iochannel.h" #include "util.h" #include "socket-util.h" @@ -189,7 +193,19 @@ ssize_t pa_iochannel_write(struct pa_iochannel*io, const void*data, size_t l) { ssize_t r; assert(io && data && l && io->ofd >= 0); - if ((r = write(io->ofd, data, l)) >= 0) { +#ifdef OS_IS_WIN32 + r = send(io->ofd, data, l, 0); + if (r < 0) { + if (WSAGetLastError() != WSAENOTSOCK) { + errno = WSAGetLastError(); + return r; + } + } + + if (r < 0) +#endif + r = write(io->ofd, data, l); + if (r >= 0) { io->writable = 0; enable_mainloop_sources(io); } @@ -201,7 +217,19 @@ ssize_t pa_iochannel_read(struct pa_iochannel*io, void*data, size_t l) { ssize_t r; assert(io && data && io->ifd >= 0); - if ((r = read(io->ifd, data, l)) >= 0) { +#ifdef OS_IS_WIN32 + r = recv(io->ifd, data, l, 0); + if (r < 0) { + if (WSAGetLastError() != WSAENOTSOCK) { + errno = WSAGetLastError(); + return r; + } + } + + if (r < 0) +#endif + r = read(io->ifd, data, l); + if (r >= 0) { io->readable = 0; enable_mainloop_sources(io); } -- cgit