Odil
A C++11 library for the DICOM standard
Toggle main menu visibility
Loading...
Searching...
No Matches
Transport.h
Go to the documentation of this file.
1
/*************************************************************************
2
* odil - Copyright (C) Universite de Strasbourg
3
* Distributed under the terms of the CeCILL-B license, as published by
4
* the CEA-CNRS-INRIA. Refer to the LICENSE file or to
5
* http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
6
* for details.
7
************************************************************************/
8
9
#ifndef _1619bae8_acba_4bf8_8205_aa8dd0085c66
10
#define _1619bae8_acba_4bf8_8205_aa8dd0085c66
11
12
#include <memory>
13
#include <string>
14
15
#include <chrono>
16
17
#include <boost/asio.hpp>
18
19
// NOTE: the io_service type alias has been removed in boost 1.87.0
20
#if BOOST_VERSION >= 108700
21
namespace
boost
22
{
23
namespace
asio
24
{
25
using
io_service = io_context;
26
}
27
}
28
#endif
29
30
#include "
odil/odil.h
"
31
32
namespace
odil
33
{
34
35
namespace
dul
36
{
37
45
struct
ODIL_API
Transport
46
{
48
typedef
boost::asio::ip::tcp::socket
Socket
;
49
51
typedef
boost::asio::steady_timer::duration
duration_type
;
52
54
Transport
();
55
57
~Transport
();
58
60
boost::asio::io_service
const
&
get_service
()
const
;
61
63
boost::asio::io_service &
get_service
();
64
66
std::shared_ptr<Socket const>
get_socket
()
const
;
67
69
std::shared_ptr<Socket>
get_socket
();
70
72
duration_type
get_timeout
()
const
;
73
75
void
set_timeout
(
duration_type
timeout);
76
78
bool
is_open
()
const
;
79
81
void
connect
(Socket::endpoint_type
const
& peer_endpoint);
82
87
void
receive
(Socket::endpoint_type
const
& endpoint);
88
90
void
close
();
91
93
std::string
read
(std::size_t length);
94
96
void
write
(std::string
const
& data);
97
98
private
:
99
boost::asio::io_service _service;
100
std::shared_ptr<Socket> _socket;
101
duration_type
_timeout;
102
boost::asio::steady_timer _deadline;
103
104
std::shared_ptr<boost::asio::ip::tcp::acceptor> _acceptor;
105
106
enum class
Source
107
{
108
NONE,
109
TIMER,
110
OPERATION,
111
};
112
113
void
_start_deadline(Source & source, boost::system::error_code & error);
114
void
_stop_deadline();
115
116
void
_run(Source & source, boost::system::error_code & error);
117
};
118
119
}
120
121
}
122
123
#endif
// _1619bae8_acba_4bf8_8205_aa8dd0085c66
odil::dul
Definition
EventData.h:24
odil
Definition
Association.h:25
odil.h
ODIL_API
#define ODIL_API
Definition
odil.h:28
odil::dul::Transport::~Transport
~Transport()
Destructor.
odil::dul::Transport::get_timeout
duration_type get_timeout() const
Return the timeout, default to infinity.
odil::dul::Transport::get_socket
std::shared_ptr< Socket const > get_socket() const
Return the socket.
odil::dul::Transport::is_open
bool is_open() const
Test whether the transport is open.
odil::dul::Transport::receive
void receive(Socket::endpoint_type const &endpoint)
Receive a connection on the specified endpoint, raise an exception upon error.
odil::dul::Transport::read
std::string read(std::size_t length)
Read data, raise an exception on error.
odil::dul::Transport::get_socket
std::shared_ptr< Socket > get_socket()
Return the socket.
odil::dul::Transport::close
void close()
Close the connection.
odil::dul::Transport::get_service
boost::asio::io_service & get_service()
Return the io_service.
odil::dul::Transport::Transport
Transport()
Constructor.
odil::dul::Transport::duration_type
boost::asio::steady_timer::duration duration_type
Duration of the timeout.
Definition
Transport.h:51
odil::dul::Transport::get_service
boost::asio::io_service const & get_service() const
Return the io_service.
odil::dul::Transport::Socket
boost::asio::ip::tcp::socket Socket
Socket type.
Definition
Transport.h:48
odil::dul::Transport::connect
void connect(Socket::endpoint_type const &peer_endpoint)
Connect to the specified endpoint, raise an exception upon error.
odil::dul::Transport::write
void write(std::string const &data)
Write data, raise an exception on error.
odil::dul::Transport::set_timeout
void set_timeout(duration_type timeout)
Set the timeout.
src
odil
dul
Transport.h
Generated by
1.17.0