1//
2// local/datagram_protocol.hpp
3// ~~~~~~~~~~~~~~~~~~~~~~~~~~~
4//
5// Copyright (c) 2003-2015 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_LOCAL_DATAGRAM_PROTOCOL_HPP
12#define BOOST_ASIO_LOCAL_DATAGRAM_PROTOCOL_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/config.hpp>
19
20#if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS) \
21 || defined(GENERATING_DOCUMENTATION)
22
23#include <boost/asio/basic_datagram_socket.hpp>
24#include <boost/asio/detail/socket_types.hpp>
25#include <boost/asio/local/basic_endpoint.hpp>
26
27#include <boost/asio/detail/push_options.hpp>
28
29namespace boost {
30namespace asio {
31namespace local {
32
33/// Encapsulates the flags needed for datagram-oriented UNIX sockets.
34/**
35 * The boost::asio::local::datagram_protocol class contains flags necessary for
36 * datagram-oriented UNIX domain sockets.
37 *
38 * @par Thread Safety
39 * @e Distinct @e objects: Safe.@n
40 * @e Shared @e objects: Safe.
41 *
42 * @par Concepts:
43 * Protocol.
44 */
45class datagram_protocol
46{
47public:
48 /// Obtain an identifier for the type of the protocol.
49 int type() const
50 {
51 return SOCK_DGRAM;
52 }
53
54 /// Obtain an identifier for the protocol.
55 int protocol() const
56 {
57 return 0;
58 }
59
60 /// Obtain an identifier for the protocol family.
61 int family() const
62 {
63 return AF_UNIX;
64 }
65
66 /// The type of a UNIX domain endpoint.
67 typedef basic_endpoint<datagram_protocol> endpoint;
68
69 /// The UNIX domain socket type.
70 typedef basic_datagram_socket<datagram_protocol> socket;
71};
72
73} // namespace local
74} // namespace asio
75} // namespace boost
76
77#include <boost/asio/detail/pop_options.hpp>
78
79#endif // defined(BOOST_ASIO_HAS_LOCAL_SOCKETS)
80 // || defined(GENERATING_DOCUMENTATION)
81
82#endif // BOOST_ASIO_LOCAL_DATAGRAM_PROTOCOL_HPP
83

source code of boost/boost/asio/local/datagram_protocol.hpp