2
// win_fd_set_adapter.hpp
3
// ~~~~~~~~~~~~~~~~~~~~~~
5
// Copyright (c) 2003-2007 Christopher M. Kohlhoff (chris at kohlhoff dot com)
7
// Distributed under the Boost Software License, Version 1.0. (See accompanying
8
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
11
#ifndef ASIO_DETAIL_WIN_FD_SET_ADAPTER_HPP
12
#define ASIO_DETAIL_WIN_FD_SET_ADAPTER_HPP
14
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
16
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
18
#include "asio/detail/push_options.hpp"
20
#include "asio/detail/socket_types.hpp"
22
#if defined(BOOST_WINDOWS) || defined(__CYGWIN__)
27
// Adapts the FD_SET type to meet the Descriptor_Set concept's requirements.
28
class win_fd_set_adapter
31
enum { win_fd_set_size = 1024 };
34
: max_descriptor_(invalid_socket)
39
void set(socket_type descriptor)
41
for (u_int i = 0; i < fd_set_.fd_count; ++i)
42
if (fd_set_.fd_array[i] == descriptor)
44
if (fd_set_.fd_count < win_fd_set_size)
45
fd_set_.fd_array[fd_set_.fd_count++] = descriptor;
48
bool is_set(socket_type descriptor) const
50
return !!__WSAFDIsSet(descriptor,
51
const_cast<fd_set*>(reinterpret_cast<const fd_set*>(&fd_set_)));
56
return reinterpret_cast<fd_set*>(&fd_set_);
59
socket_type max_descriptor() const
61
return max_descriptor_;
65
// This structure is defined to be compatible with the Windows API fd_set
66
// structure, but without being dependent on the value of FD_SETSIZE.
70
SOCKET fd_array[win_fd_set_size];
74
socket_type max_descriptor_;
80
#endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
82
#include "asio/detail/pop_options.hpp"
84
#endif // ASIO_DETAIL_WIN_FD_SET_ADAPTER_HPP