updated changelog for 1.9.0
[deb_libcec.git] / src / lib / platform / posix / os-socket.h
index 468cc3deb4dfa075a60bff9cd2ca899e8ac0d5d8..7539aab3e6289e91ab594704399e04ddecebe67f 100644 (file)
@@ -32,8 +32,8 @@
  */
 
 
-#include "../os.h"
-#include "../util/timeutils.h"
+#include "lib/platform/os.h"
+#include "lib/platform/util/timeutils.h"
 #include <stdio.h>
 #include <fcntl.h>
 #include <sys/socket.h>
 #include <netdb.h>
 #include <poll.h>
 
+/* Needed on Mac OS/X */
+#ifndef SOL_TCP
+#define SOL_TCP IPPROTO_TCP
+#endif
+
 namespace PLATFORM
 {
   // Standard sockets
@@ -71,7 +76,7 @@ namespace PLATFORM
     if (socket == INVALID_SOCKET_VALUE)
     {
       *iError = EINVAL;
-      return -1;
+      return -EINVAL;
     }
 
     ssize_t iBytesWritten(0);
@@ -85,19 +90,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;
     }
@@ -116,7 +121,7 @@ namespace PLATFORM
     if (socket == INVALID_SOCKET_VALUE)
     {
       *iError = EINVAL;
-      return -1;
+      return -EINVAL;
     }
 
     if (iTimeoutMs > 0)
@@ -145,7 +150,7 @@ namespace PLATFORM
       if (returnv == -1)
       {
         *iError = errno;
-        return -1;
+        return -errno;
       }
       else if (returnv == 0)
       {
@@ -156,7 +161,7 @@ namespace PLATFORM
       if (returnv == -1)
       {
         *iError = errno;
-        return -1;
+        return -errno;
       }
 
       iBytesRead += returnv;
@@ -205,7 +210,7 @@ namespace PLATFORM
     if (socket == INVALID_SOCKET_VALUE)
     {
       *iError = EINVAL;
-      return -1;
+      return -EINVAL;
     }
 
     if (iTimeoutMs > 0)