Remote Call Framework 3.2
Asio.hpp
1 
2 //******************************************************************************
3 // RCF - Remote Call Framework
4 //
5 // Copyright (c) 2005 - 2020, Delta V Software. All rights reserved.
6 // http://www.deltavsoft.com
7 //
8 // RCF is distributed under dual licenses - closed source or GPL.
9 // Consult your particular license for conditions of use.
10 //
11 // If you have not purchased a commercial license, you are using RCF
12 // under GPL terms.
13 //
14 // Version: 3.2
15 // Contact: support <at> deltavsoft.com
16 //
17 //******************************************************************************
18 
19 #ifndef INCLUDE_RCF_ASIO_HPP
20 #define INCLUDE_RCF_ASIO_HPP
21 
22 #include <algorithm> // std::min, std::max
23 
24 // VS 2013 Update 3 - a number of WinSock functions have been deprecated.
25 #ifdef _MSC_VER
26 #pragma warning(push)
27 #pragma warning(disable: 4996) // error C4996: 'WSAAddressToStringA': Use WSAAddressToStringW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
28 #endif
29 
30 #include <RCF/Config.hpp>
31 #include <RCF/AsioFwd.hpp>
32 
33 #if defined(RCF_WINDOWS) || defined(__CYGWIN__)
34 # if defined(_WINSOCKAPI_) && !defined(_WINSOCK2API_)
35 # error WinSock.h has already been included. Define WIN32_LEAN_AND_MEAN in your build, to avoid implicit inclusion of WinSock.h.
36 # endif // defined(_WINSOCKAPI_) && !defined(_WINSOCK2API_)
37 #endif
38 
39 #ifdef RCF_USE_BOOST_ASIO
40 #include <boost/asio.hpp>
41 #else
42 #include <RCF/external/asio/asio.hpp>
43 #endif
44 
45 // Do we have local sockets?
46 #ifdef RCF_USE_BOOST_ASIO
47 #ifdef BOOST_ASIO_HAS_LOCAL_SOCKETS
48 #define RCF_HAS_LOCAL_SOCKETS
49 #endif
50 #else
51 #ifdef ASIO_HAS_LOCAL_SOCKETS
52 #define RCF_HAS_LOCAL_SOCKETS
53 #endif
54 #endif
55 
56 #include <RCF/AsioDeadlineTimer.hpp>
57 
58 namespace RCF {
59 
60 
61  typedef ASIO_NS::ip::tcp::socket AsioSocket;
62  typedef std::shared_ptr<AsioSocket> AsioSocketPtr;
63 
64  typedef ASIO_NS::const_buffer AsioConstBuffer;
65 
66  typedef AsioSocket TcpSocket;
67  typedef std::shared_ptr<TcpSocket> TcpSocketPtr;
68 
69 #ifdef RCF_HAS_LOCAL_SOCKETS
70 
71  using ASIO_NS::local::stream_protocol;
72  typedef stream_protocol::socket UnixLocalSocket;
73  typedef std::shared_ptr<UnixLocalSocket> UnixLocalSocketPtr;
74 
75 #else
76 
77  typedef TcpSocket UnixLocalSocket;
78  typedef TcpSocketPtr UnixLocalSocketPtr;
79 
80 #endif
81 
82 } // namespace RCF
83 
84 #ifdef _MSC_VER
85 #pragma warning(pop)
86 #endif
87 
88 #endif // ! INCLUDE_RCF_ASIO_HPP
Definition: AmiIoHandler.hpp:24