00001 // 00002 // posix_fd_set_adapter.hpp 00003 // ~~~~~~~~~~~~~~~~~~~~~~~~ 00004 // 00005 // Copyright (c) 2003-2007 Christopher M. Kohlhoff (chris at kohlhoff dot com) 00006 // 00007 // Distributed under the Boost Software License, Version 1.0. (See accompanying 00008 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 00009 // 00010 00011 #ifndef ASIO_DETAIL_POSIX_FD_SET_ADAPTER_HPP 00012 #define ASIO_DETAIL_POSIX_FD_SET_ADAPTER_HPP 00013 00014 #if defined(_MSC_VER) && (_MSC_VER >= 1200) 00015 # pragma once 00016 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 00017 00018 #include "asio/detail/push_options.hpp" 00019 00020 #include "asio/detail/socket_types.hpp" 00021 00022 #if !defined(BOOST_WINDOWS) && !defined(__CYGWIN__) 00023 00024 namespace asio { 00025 namespace detail { 00026 00027 // Adapts the FD_SET type to meet the Descriptor_Set concept's requirements. 00028 class posix_fd_set_adapter 00029 { 00030 public: 00031 posix_fd_set_adapter() 00032 : max_descriptor_(invalid_socket) 00033 { 00034 using namespace std; // Needed for memset on Solaris. 00035 FD_ZERO(&fd_set_); 00036 } 00037 00038 void set(socket_type descriptor) 00039 { 00040 if (max_descriptor_ == invalid_socket || descriptor > max_descriptor_) 00041 max_descriptor_ = descriptor; 00042 FD_SET(descriptor, &fd_set_); 00043 } 00044 00045 bool is_set(socket_type descriptor) const 00046 { 00047 return FD_ISSET(descriptor, &fd_set_) != 0; 00048 } 00049 00050 operator fd_set*() 00051 { 00052 return &fd_set_; 00053 } 00054 00055 socket_type max_descriptor() const 00056 { 00057 return max_descriptor_; 00058 } 00059 00060 private: 00061 fd_set fd_set_; 00062 socket_type max_descriptor_; 00063 }; 00064 00065 } // namespace detail 00066 } // namespace asio 00067 00068 #endif // !defined(BOOST_WINDOWS) && !defined(__CYGWIN__) 00069 00070 #include "asio/detail/pop_options.hpp" 00071 00072 #endif // ASIO_DETAIL_POSIX_FD_SET_ADAPTER_HPP
1.5.6