X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Flib%2Fplatform%2Fposix%2Fos-socket.h;h=739c6a71823d76ee002f306fb11888325775010e;hb=ebcedb051be7d8e1e19ecd3f0aa164baae252400;hp=30be947159d2fe9c64ed90f30be9e8fa7ee31799;hpb=1a47476aaf672a655ad19333e321c5e3b8efb73b;p=deb_libcec.git diff --git a/src/lib/platform/posix/os-socket.h b/src/lib/platform/posix/os-socket.h index 30be947..739c6a7 100644 --- a/src/lib/platform/posix/os-socket.h +++ b/src/lib/platform/posix/os-socket.h @@ -32,10 +32,11 @@ */ -#include "../os.h" -#include "../util/timeutils.h" +#include "lib/platform/os.h" +#include "lib/platform/util/timeutils.h" #include #include +#include #include #include #include @@ -76,7 +77,7 @@ namespace PLATFORM if (socket == INVALID_SOCKET_VALUE) { *iError = EINVAL; - return -1; + return -EINVAL; } ssize_t iBytesWritten(0); @@ -86,23 +87,23 @@ namespace PLATFORM { FD_ZERO(&port); FD_SET(socket, &port); - int returnv = select(socket + 1, NULL, &port, NULL, tv); + ssize_t returnv = (ssize_t)select(socket + 1, NULL, &port, NULL, tv); if (returnv < 0) { *iError = errno; - return -1; + return -errno; } else if (returnv == 0) { *iError = ETIMEDOUT; - return -1; + return -ETIMEDOUT; } returnv = write(socket, (char*)data + iBytesWritten, len - iBytesWritten); if (returnv == -1) { *iError = errno; - return -1; + return -errno; } iBytesWritten += returnv; } @@ -121,7 +122,7 @@ namespace PLATFORM if (socket == INVALID_SOCKET_VALUE) { *iError = EINVAL; - return -1; + return -EINVAL; } if (iTimeoutMs > 0) @@ -145,12 +146,12 @@ namespace PLATFORM FD_ZERO(&port); FD_SET(socket, &port); - int32_t returnv = select(socket + 1, &port, NULL, NULL, tv); + ssize_t returnv = (ssize_t)select(socket + 1, &port, NULL, NULL, tv); if (returnv == -1) { *iError = errno; - return -1; + return -errno; } else if (returnv == 0) { @@ -161,7 +162,7 @@ namespace PLATFORM if (returnv == -1) { *iError = errno; - return -1; + return -errno; } iBytesRead += returnv; @@ -172,6 +173,20 @@ namespace PLATFORM return iBytesRead; } + + inline int SocketIoctl(socket_t socket, int *iError, int request, void* data) + { + if (socket == INVALID_SOCKET_VALUE) + { + *iError = EINVAL; + return -1; + } + + int iReturn = ioctl(socket, request, data); + if (iReturn < 0) + *iError = errno; + return iReturn; + } //@} // TCP @@ -210,7 +225,7 @@ namespace PLATFORM if (socket == INVALID_SOCKET_VALUE) { *iError = EINVAL; - return -1; + return -EINVAL; } if (iTimeoutMs > 0) @@ -228,7 +243,7 @@ namespace PLATFORM { if (iTimeoutMs > 0) { - int iPollResult = poll(&fds, 1, iTarget - iNow); + int iPollResult = poll(&fds, 1, (int)(iTarget - iNow)); if (iPollResult == 0) { *iError = ETIMEDOUT; @@ -305,7 +320,7 @@ namespace PLATFORM pfd.events = POLLOUT; pfd.revents = 0; - int iPollResult = poll(&pfd, 1, iTimeout); + int iPollResult = poll(&pfd, 1, (int)iTimeout); if (iPollResult == 0) *iError = ETIMEDOUT; else if (iPollResult == -1)