Boost logo

Boost-Commit :

From: chris_at_[hidden]
Date: 2007-08-20 10:07:23


Author: chris_kohlhoff
Date: 2007-08-20 10:07:23 EDT (Mon, 20 Aug 2007)
New Revision: 38784
URL: http://svn.boost.org/trac/boost/changeset/38784

Log:
Add a workaround for Windows Vista's handling of the boolean socket option
tcp::no_delay, where ::getsockopt will return the size of the option as one
byte, even though a four byte integer was passed in.

Text files modified:
   trunk/boost/asio/detail/socket_option.hpp | 13 ++++++++++++-
   1 files changed, 12 insertions(+), 1 deletions(-)

Modified: trunk/boost/asio/detail/socket_option.hpp
==============================================================================
--- trunk/boost/asio/detail/socket_option.hpp (original)
+++ trunk/boost/asio/detail/socket_option.hpp 2007-08-20 10:07:23 EDT (Mon, 20 Aug 2007)
@@ -111,8 +111,19 @@
   template <typename Protocol>
   void resize(const Protocol&, std::size_t s)
   {
- if (s != sizeof(value_))
+ // On some platforms (e.g. Windows Vista), the getsockopt function will
+ // return the size of a boolean socket option as one byte, even though a
+ // four byte integer was passed in.
+ switch (s)
+ {
+ case sizeof(char):
+ value_ = *reinterpret_cast<char*>(&value_) ? 1 : 0;
+ break;
+ case sizeof(value_):
+ break;
+ default:
       throw std::length_error("boolean socket option resize");
+ }
   }
 
 private:


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk