diff options
author | Benoit Foucher <benoit@zeroc.com> | 2006-02-17 16:40:01 +0000 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2006-02-17 16:40:01 +0000 |
commit | 85b846e8066528c3c43374e4f98316a3eae7ed07 (patch) | |
tree | 9cec48d47e7e6269ba3a8cc16c5223c832ee3e52 /cppe/src/IceE/Network.cpp | |
parent | Refactored TAO tests. (diff) | |
download | ice-85b846e8066528c3c43374e4f98316a3eae7ed07.tar.bz2 ice-85b846e8066528c3c43374e4f98316a3eae7ed07.tar.xz ice-85b846e8066528c3c43374e4f98316a3eae7ed07.zip |
- Changes to use blocking sockets instead of non-blocking sockets.
- Removed timeout in accept() method.
Diffstat (limited to 'cppe/src/IceE/Network.cpp')
-rw-r--r-- | cppe/src/IceE/Network.cpp | 59 |
1 files changed, 19 insertions, 40 deletions
diff --git a/cppe/src/IceE/Network.cpp b/cppe/src/IceE/Network.cpp index 1c9b430d1cf..b7448fa4843 100644 --- a/cppe/src/IceE/Network.cpp +++ b/cppe/src/IceE/Network.cpp @@ -334,6 +334,24 @@ IceInternal::setBlock(SOCKET fd, bool block) } } +#ifdef ICEE_USE_SOCKET_TIMEOUT +void +IceInternal::setTimeout(SOCKET fd, bool recv, int timeout) +{ + assert(timeout != 0); + struct timeval tv; + tv.tv_sec = timeout > 0 ? timeout / 1000 : 0; + tv.tv_usec = timeout > 0 ? (timeout - tv.tv_sec * 1000) * 1000 : 0; + if(setsockopt(fd, SOL_SOCKET, recv ? SO_RCVTIMEO : SO_SNDTIMEO, (char*)&tv, (int)sizeof(timeval)) == SOCKET_ERROR) + { + closeSocketNoThrow(fd); + SocketException ex(__FILE__, __LINE__); + ex.error = getSocketErrno(); + throw ex; + } +} +#endif + void IceInternal::setTcpNoDelay(SOCKET fd) { @@ -924,7 +942,7 @@ IceInternal::acceptInterrupted() } SOCKET -IceInternal::doAccept(SOCKET fd, int timeout) +IceInternal::doAccept(SOCKET fd) { int ret; @@ -936,45 +954,6 @@ repeatAccept: goto repeatAccept; } - if(wouldBlock()) - { - repeatSelect: - int rs; - fd_set fdSet; - FD_ZERO(&fdSet); - FD_SET(fd, &fdSet); - if(timeout >= 0) - { - struct timeval tv; - tv.tv_sec = timeout / 1000; - tv.tv_usec = (timeout - tv.tv_sec * 1000) * 1000; - rs = ::select(fd + 1, &fdSet, 0, 0, &tv); - } - else - { - rs = ::select(fd + 1, &fdSet, 0, 0, 0); - } - - if(rs == SOCKET_ERROR) - { - if(interrupted()) - { - goto repeatSelect; - } - - SocketException ex(__FILE__, __LINE__); - ex.error = getSocketErrno(); - throw ex; - } - - if(rs == 0) - { - throw TimeoutException(__FILE__, __LINE__); - } - - goto repeatAccept; - } - SocketException ex(__FILE__, __LINE__); ex.error = getSocketErrno(); throw ex; |