Realistic 3D camera system
3D camera system components
Main Page
Modules
Namespaces
Classes
Files
File List
File Members
asio-1.10.6
include
asio
detail
socket_holder.hpp
Go to the documentation of this file.
1
//
2
// detail/socket_holder.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 ASIO_DETAIL_SOCKET_HOLDER_HPP
12
#define ASIO_DETAIL_SOCKET_HOLDER_HPP
13
14
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
15
# pragma once
16
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17
18
#include "
asio/detail/config.hpp
"
19
#include "
asio/detail/noncopyable.hpp
"
20
#include "
asio/detail/socket_ops.hpp
"
21
22
#include "
asio/detail/push_options.hpp
"
23
24
namespace
asio
{
25
namespace
detail {
26
27
// Implement the resource acquisition is initialisation idiom for sockets.
28
class
socket_holder
29
:
private
noncopyable
30
{
31
public
:
32
// Construct as an uninitialised socket.
33
socket_holder
()
34
: socket_(
invalid_socket
)
35
{
36
}
37
38
// Construct to take ownership of the specified socket.
39
explicit
socket_holder
(
socket_type
s
)
40
: socket_(s)
41
{
42
}
43
44
// Destructor.
45
~socket_holder
()
46
{
47
if
(socket_ !=
invalid_socket
)
48
{
49
asio::error_code
ec;
50
socket_ops::state_type
state = 0;
51
socket_ops::close
(socket_, state,
true
, ec);
52
}
53
}
54
55
// Get the underlying socket.
56
socket_type
get
()
const
57
{
58
return
socket_;
59
}
60
61
// Reset to an uninitialised socket.
62
void
reset
()
63
{
64
if
(socket_ !=
invalid_socket
)
65
{
66
asio::error_code
ec;
67
socket_ops::state_type
state = 0;
68
socket_ops::close
(socket_, state,
true
, ec);
69
socket_ =
invalid_socket
;
70
}
71
}
72
73
// Reset to take ownership of the specified socket.
74
void
reset
(
socket_type
s
)
75
{
76
reset
();
77
socket_ =
s
;
78
}
79
80
// Release ownership of the socket.
81
socket_type
release
()
82
{
83
socket_type
tmp = socket_;
84
socket_ =
invalid_socket
;
85
return
tmp;
86
}
87
88
private
:
89
// The underlying socket.
90
socket_type
socket_;
91
};
92
93
}
// namespace detail
94
}
// namespace asio
95
96
#include "
asio/detail/pop_options.hpp
"
97
98
#endif // ASIO_DETAIL_SOCKET_HOLDER_HPP
asio::detail::socket_holder::~socket_holder
~socket_holder()
Definition:
socket_holder.hpp:45
asio::s
SocketService & s
Definition:
connect.hpp:521
asio::detail::socket_holder::reset
void reset()
Definition:
socket_holder.hpp:62
config.hpp
asio::detail::noncopyable
Definition:
noncopyable.hpp:25
socket_ops.hpp
push_options.hpp
asio::detail::socket_holder::release
socket_type release()
Definition:
socket_holder.hpp:81
asio::detail::socket_type
int socket_type
Definition:
socket_types.hpp:277
pop_options.hpp
noncopyable.hpp
asio::detail::socket_holder::socket_holder
socket_holder()
Definition:
socket_holder.hpp:33
asio::detail::socket_ops::state_type
unsigned char state_type
Definition:
socket_ops.hpp:59
asio::error_code
Class to represent an error code value.
Definition:
error_code.hpp:80
asio::detail::socket_holder
Definition:
socket_holder.hpp:28
asio::detail::invalid_socket
const int invalid_socket
Definition:
socket_types.hpp:278
asio::detail::socket_holder::reset
void reset(socket_type s)
Definition:
socket_holder.hpp:74
asio::detail::socket_holder::socket_holder
socket_holder(socket_type s)
Definition:
socket_holder.hpp:39
asio
Definition:
async_result.hpp:23
asio::detail::socket_ops::close
int close(socket_type s, state_type &state, bool destruction, asio::error_code &ec)
Definition:
socket_ops.ipp:295
Generated by
1.8.11