PageRenderTime 22ms CodeModel.GetById 14ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/src/contrib/boost/asio/ip/udp.hpp

http://pythonocc.googlecode.com/
C++ Header | 118 lines | 63 code | 22 blank | 33 comment | 3 complexity | 7ea09f6bb7729aa7763a9c6c00f00e6b MD5 | raw file
  1//
  2// udp.hpp
  3// ~~~~~~~
  4//
  5// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com)
  6//
  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)
  9//
 10
 11#ifndef BOOST_ASIO_IP_UDP_HPP
 12#define BOOST_ASIO_IP_UDP_HPP
 13
 14#if defined(_MSC_VER) && (_MSC_VER >= 1200)
 15# pragma once
 16#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
 17
 18#include <boost/asio/detail/push_options.hpp>
 19
 20#include <boost/asio/basic_datagram_socket.hpp>
 21#include <boost/asio/ip/basic_endpoint.hpp>
 22#include <boost/asio/ip/basic_resolver.hpp>
 23#include <boost/asio/ip/basic_resolver_iterator.hpp>
 24#include <boost/asio/ip/basic_resolver_query.hpp>
 25#include <boost/asio/detail/socket_types.hpp>
 26
 27namespace boost {
 28namespace asio {
 29namespace ip {
 30
 31/// Encapsulates the flags needed for UDP.
 32/**
 33 * The boost::asio::ip::udp class contains flags necessary for UDP sockets.
 34 *
 35 * @par Thread Safety
 36 * @e Distinct @e objects: Safe.@n
 37 * @e Shared @e objects: Safe.
 38 *
 39 * @par Concepts:
 40 * Protocol, InternetProtocol.
 41 */
 42class udp
 43{
 44public:
 45  /// The type of a UDP endpoint.
 46  typedef basic_endpoint<udp> endpoint;
 47
 48  /// (Deprecated: use resolver::query.) The type of a resolver query.
 49  typedef basic_resolver_query<udp> resolver_query;
 50
 51  /// (Deprecated: use resolver::iterator.) The type of a resolver iterator.
 52  typedef basic_resolver_iterator<udp> resolver_iterator;
 53
 54  /// Construct to represent the IPv4 UDP protocol.
 55  static udp v4()
 56  {
 57    return udp(PF_INET);
 58  }
 59
 60  /// Construct to represent the IPv6 UDP protocol.
 61  static udp v6()
 62  {
 63    return udp(PF_INET6);
 64  }
 65
 66  /// Obtain an identifier for the type of the protocol.
 67  int type() const
 68  {
 69    return SOCK_DGRAM;
 70  }
 71
 72  /// Obtain an identifier for the protocol.
 73  int protocol() const
 74  {
 75    return IPPROTO_UDP;
 76  }
 77
 78  /// Obtain an identifier for the protocol family.
 79  int family() const
 80  {
 81    return family_;
 82  }
 83
 84  /// The UDP socket type.
 85  typedef basic_datagram_socket<udp> socket;
 86
 87  /// The UDP resolver type.
 88  typedef basic_resolver<udp> resolver;
 89
 90  /// Compare two protocols for equality.
 91  friend bool operator==(const udp& p1, const udp& p2)
 92  {
 93    return p1.family_ == p2.family_;
 94  }
 95
 96  /// Compare two protocols for inequality.
 97  friend bool operator!=(const udp& p1, const udp& p2)
 98  {
 99    return p1.family_ != p2.family_;
100  }
101
102private:
103  // Construct with a specific family.
104  explicit udp(int family)
105    : family_(family)
106  {
107  }
108
109  int family_;
110};
111
112} // namespace ip
113} // namespace asio
114} // namespace boost
115
116#include <boost/asio/detail/pop_options.hpp>
117
118#endif // BOOST_ASIO_IP_UDP_HPP