repositories
/
deb_libcec.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
LibCecSharp: fixed - set the primary LA in CecLogicalAddresses
[deb_libcec.git]
/
src
/
lib
/
platform
/
windows
/
os-socket.h
diff --git
a/src/lib/platform/windows/os-socket.h
b/src/lib/platform/windows/os-socket.h
index 60badd78372a9a91d8655489466d6607af00f98b..0c3855558ddeb7b164d151cb3e1e50ca0fa1cdee 100644
(file)
--- a/
src/lib/platform/windows/os-socket.h
+++ b/
src/lib/platform/windows/os-socket.h
@@
-31,8
+31,8
@@
* http://www.pulse-eight.net/
*/
* http://www.pulse-eight.net/
*/
-#include "
..
/os.h"
-#include "
..
/util/timeutils.h"
+#include "
lib/platform
/os.h"
+#include "
lib/platform
/util/timeutils.h"
#include <ws2spi.h>
#include <ws2ipdef.h>
#include <ws2spi.h>
#include <ws2ipdef.h>
@@
-147,7
+147,7
@@
namespace PLATFORM
ssize_t iReturn = send(socket, (char*)data, (int)len, 0);
if (iReturn < (ssize_t)len)
ssize_t iReturn = send(socket, (char*)data, (int)len, 0);
if (iReturn < (ssize_t)len)
- *iError =
errno
;
+ *iError =
GetSocketError()
;
return iReturn;
}
return iReturn;
}
@@
-181,22
+181,33
@@
namespace PLATFORM
tv.tv_usec = 1000 * (long)(iTimeoutMs % 1000);
FD_ZERO(&fd_read);
tv.tv_usec = 1000 * (long)(iTimeoutMs % 1000);
FD_ZERO(&fd_read);
+ #pragma warning(disable:4127) /* disable 'conditional expression is constant' */
FD_SET(socket, &fd_read);
FD_SET(socket, &fd_read);
+ #pragma warning(default:4127)
if (select((int)socket + 1, &fd_read, NULL, NULL, &tv) == 0)
if (select((int)socket + 1, &fd_read, NULL, NULL, &tv) == 0)
+ {
+ *iError = ETIMEDOUT;
return ETIMEDOUT;
return ETIMEDOUT;
+ }
TcpSocketSetBlocking(socket, false);
}
ssize_t iReadResult = (iTimeoutMs > 0) ?
TcpSocketSetBlocking(socket, false);
}
ssize_t iReadResult = (iTimeoutMs > 0) ?
- recv(socket, (char*)data + iBytesRead, (int)(len - iBytesRead),
MSG_WAITALL
) :
+ recv(socket, (char*)data + iBytesRead, (int)(len - iBytesRead),
0
) :
recv(socket, (char*)data, (int)len, MSG_WAITALL);
*iError = GetSocketError();
recv(socket, (char*)data, (int)len, MSG_WAITALL);
*iError = GetSocketError();
+
+ if (iTimeoutMs > 0)
+ {
+ TcpSocketSetBlocking(socket, true);
+ iNow = GetTimeMs();
+ }
+
if (iReadResult < 0)
{
if (iReadResult < 0)
{
- if (
errno
== EAGAIN && iTimeoutMs > 0)
+ if (
*iError
== EAGAIN && iTimeoutMs > 0)
continue;
continue;
- *iError = errno;
return -1;
}
else if (iReadResult == 0 || (iReadResult != (ssize_t)len && iTimeoutMs == 0))
return -1;
}
else if (iReadResult == 0 || (iReadResult != (ssize_t)len && iTimeoutMs == 0))
@@
-206,14
+217,12
@@
namespace PLATFORM
}
iBytesRead += iReadResult;
}
iBytesRead += iReadResult;
-
- if (iTimeoutMs > 0)
- {
- TcpSocketSetBlocking(socket, true);
- iNow = GetTimeMs();
- }
}
}
- return 0;
+
+ if (iBytesRead < (ssize_t)len && *iError == 0)
+ *iError = ETIMEDOUT;
+
+ return iBytesRead;
}
inline bool TcpResolveAddress(const char *strHost, uint16_t iPort, int *iError, struct addrinfo **info)
}
inline bool TcpResolveAddress(const char *strHost, uint16_t iPort, int *iError, struct addrinfo **info)
@@
-263,8
+272,10
@@
namespace PLATFORM
FD_ZERO(&fd_write);
FD_ZERO(&fd_except);
FD_ZERO(&fd_write);
FD_ZERO(&fd_except);
+ #pragma warning(disable:4127) /* disable 'conditional expression is constant' */
FD_SET(socket, &fd_write);
FD_SET(socket, &fd_except);
FD_SET(socket, &fd_write);
FD_SET(socket, &fd_except);
+ #pragma warning(default:4127)
int iPollResult = select(sizeof(socket)*8, NULL, &fd_write, &fd_except, &tv);
if (iPollResult == 0)
int iPollResult = select(sizeof(socket)*8, NULL, &fd_write, &fd_except, &tv);
if (iPollResult == 0)
@@
-279,7
+290,7
@@
namespace PLATFORM
}
else
{
}
else
{
- *iError =
errno
;
+ *iError =
GetSocketError()
;
}
}
}
}