X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Flib%2Fplatform%2Fposix%2Fos-socket.h;h=9d98d9ad9285f3646046597b9ef1a71bc35f08d9;hb=4d3a75622545306c7a5d24789d2239ed2560703f;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..9d98d9a 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); @@ -90,19 +91,19 @@ namespace PLATFORM 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) @@ -150,7 +151,7 @@ namespace PLATFORM 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)