*/
-#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/ioctl.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.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
if (socket == INVALID_SOCKET_VALUE)
{
*iError = EINVAL;
- return -1;
+ return -EINVAL;
}
ssize_t iBytesWritten(0);
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;
}
if (socket == INVALID_SOCKET_VALUE)
{
*iError = EINVAL;
- return -1;
+ return -EINVAL;
}
if (iTimeoutMs > 0)
if (returnv == -1)
{
*iError = errno;
- return -1;
+ return -errno;
}
else if (returnv == 0)
{
if (returnv == -1)
{
*iError = errno;
- return -1;
+ return -errno;
}
iBytesRead += returnv;
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
if (socket == INVALID_SOCKET_VALUE)
{
*iError = EINVAL;
- return -1;
+ return -EINVAL;
}
if (iTimeoutMs > 0)