summaryrefslogtreecommitdiff
path: root/cpp/src/Ice/UdpTransceiver.cpp
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2018-11-15 08:24:20 +0100
committerBenoit Foucher <benoit@zeroc.com>2018-11-15 08:24:20 +0100
commit1ced32aaad9731c1fc14e232dc6463159b3d48d5 (patch)
tree6cafbc5c62c564dfe7a0d27c2f6254c3485c2264 /cpp/src/Ice/UdpTransceiver.cpp
parentSet slice output to avoid warning with Android Studio (diff)
downloadice-1ced32aaad9731c1fc14e232dc6463159b3d48d5.tar.bz2
ice-1ced32aaad9731c1fc14e232dc6463159b3d48d5.tar.xz
ice-1ced32aaad9731c1fc14e232dc6463159b3d48d5.zip
Fixed SOCKET_ERROR assignement with DWORD, fixes #267
Diffstat (limited to 'cpp/src/Ice/UdpTransceiver.cpp')
-rwxr-xr-xcpp/src/Ice/UdpTransceiver.cpp27
1 files changed, 15 insertions, 12 deletions
diff --git a/cpp/src/Ice/UdpTransceiver.cpp b/cpp/src/Ice/UdpTransceiver.cpp
index 49f60a06f80..4d1a9617ca6 100755
--- a/cpp/src/Ice/UdpTransceiver.cpp
+++ b/cpp/src/Ice/UdpTransceiver.cpp
@@ -75,7 +75,7 @@ IceInternal::UdpTransceiver::initialize(Buffer& /*readBuffer*/, Buffer& /*writeB
#if defined(ICE_USE_IOCP)
doFinishConnectAsync(_fd, _write);
#elif defined(ICE_OS_UWP)
- if(_write.count == SOCKET_ERROR)
+ if(_write.error != ERROR_SUCCESS)
{
try
{
@@ -387,6 +387,7 @@ IceInternal::UdpTransceiver::startWrite(Buffer& buf)
else
{
_write.count = 0;
+ _write.error = ERROR_SUCCESS;
_writer = ref new DataWriter(safe_cast<DatagramSocket^>(_fd)->OutputStream);
}
}
@@ -409,6 +410,7 @@ IceInternal::UdpTransceiver::startWrite(Buffer& buf)
else
{
_write.count = 0;
+ _write.error = ERROR_SUCCESS;
_writer = ref new DataWriter(operation->GetResults());
if(_mcastAddr.host != nullptr)
{
@@ -461,6 +463,7 @@ IceInternal::UdpTransceiver::startWrite(Buffer& buf)
#else
_write.buf.len = static_cast<int>(buf.b.size());
_write.buf.buf = reinterpret_cast<char*>(&*buf.i);
+ _write.error = ERROR_SUCCESS;
int err;
if(_state == StateConnected)
{
@@ -482,8 +485,7 @@ IceInternal::UdpTransceiver::startWrite(Buffer& buf)
// No peer has sent a datagram yet.
throw SocketException(__FILE__, __LINE__, 0);
}
- err = WSASendTo(_fd, &_write.buf, 1, &_write.count, 0, &_peerAddr.sa,
- len, &_write, ICE_NULLPTR);
+ err = WSASendTo(_fd, &_write.buf, 1, &_write.count, 0, &_peerAddr.sa, len, &_write, ICE_NULLPTR);
}
if(err == SOCKET_ERROR)
@@ -511,14 +513,14 @@ IceInternal::UdpTransceiver::connectCompleted(Windows::Foundation::IAsyncAction^
{
if(status != Windows::Foundation::AsyncStatus::Completed)
{
- _write.count = SOCKET_ERROR;
_write.error = action->ErrorCode.Value;
}
else
{
- _write.count = 0;
+ _write.error = ERROR_SUCCESS;
_writer = ref new DataWriter(safe_cast<DatagramSocket^>(_fd)->OutputStream);
}
+ _write.count = 0;
completed(SocketOperationConnect);
}
@@ -528,14 +530,14 @@ IceInternal::UdpTransceiver::getOutputStreamMcastCompleted(IAsyncOperation<IOutp
{
if(status != Windows::Foundation::AsyncStatus::Completed)
{
- _write.count = SOCKET_ERROR;
_write.error = operation->ErrorCode.Value;
}
else
{
- _write.count = 0;
+ _write.error = ERROR_SUCCESS;
_writer = ref new DataWriter(operation->GetResults());
}
+ _write.count = 0;
if(_mcastAddr.host != nullptr)
{
setMcastGroup(_fd, _mcastAddr, "");
@@ -555,7 +557,7 @@ IceInternal::UdpTransceiver::getOutputStreamCompleted(concurrency::task<IOutputS
}
catch(Platform::Exception^ pex)
{
- _write.count = SOCKET_ERROR;
+ _write.count = 0;
_write.error = pex->HResult;
completed(SocketOperationWrite);
}
@@ -571,7 +573,7 @@ IceInternal::UdpTransceiver::finishWrite(Buffer& buf)
return;
}
- if(static_cast<int>(_write.count) == SOCKET_ERROR)
+ if(_write.error != ERROR_SUCCESS)
{
#ifndef ICE_OS_UWP
WSASetLastError(_write.error);
@@ -602,6 +604,7 @@ IceInternal::UdpTransceiver::startRead(Buffer& buf)
#ifndef ICE_OS_UWP
_read.buf.len = packetSize;
_read.buf.buf = reinterpret_cast<char*>(&*buf.i);
+ _read.error = ERROR_SUCCESS;
int err;
if(_state == StateConnected)
{
@@ -612,8 +615,8 @@ IceInternal::UdpTransceiver::startRead(Buffer& buf)
memset(&_readAddr.saStorage, 0, sizeof(struct sockaddr_storage));
_readAddrLen = static_cast<socklen_t>(sizeof(sockaddr_storage));
- err = WSARecvFrom(_fd, &_read.buf, 1, &_read.count, &_read.flags,
- &_readAddr.sa, &_readAddrLen, &_read, ICE_NULLPTR);
+ err = WSARecvFrom(_fd, &_read.buf, 1, &_read.count, &_read.flags, &_readAddr.sa, &_readAddrLen, &_read,
+ ICE_NULLPTR);
}
if(err == SOCKET_ERROR)
@@ -683,7 +686,7 @@ IceInternal::UdpTransceiver::finishRead(Buffer& buf)
checkErrorCode(__FILE__, __LINE__, ex->HResult);
}
#else
- if(static_cast<int>(_read.count) == SOCKET_ERROR)
+ if(_read.error != ERROR_SUCCESS)
{
WSASetLastError(_read.error);