RCFProto
 All Classes Functions Typedefs
Asio.hpp
1 
2 //******************************************************************************
3 // RCF - Remote Call Framework
4 //
5 // Copyright (c) 2005 - 2013, 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: 2.0
15 // Contact: support <at> deltavsoft.com
16 //
17 //******************************************************************************
18 
19 #ifndef INCLUDE_RCF_ASIO_HPP
20 #define INCLUDE_RCF_ASIO_HPP
21 
22 // VS 2013 Update 3 - a number of WinSock functions have been deprecated.
23 #ifdef _MSC_VER
24 #pragma warning(push)
25 #pragma warning(disable: 4996) // error C4996: 'WSAAddressToStringA': Use WSAAddressToStringW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
26 #endif
27 
28 #include <RCF/Config.hpp>
29 
30 // Turn off auto-linking for Boost Date Time lib. Asio headers include some boost/date_time/ headers.
31 #define BOOST_DATE_TIME_NO_LIB
32 #define BOOST_REGEX_NO_LIB
33 
34 #include <RCF/AsioFwd.hpp>
35 
36 // Some issues with asio headers.
37 //#if defined(__MACH__) && defined(__APPLE__)
38 //#include <limits.h>
39 //#ifndef IOV_MAX
40 //#define IOV_MAX 1024
41 //#endif
42 //#endif
43 
44 #if defined(BOOST_WINDOWS) || defined(__CYGWIN__)
45 # if defined(_WINSOCKAPI_) && !defined(_WINSOCK2API_)
46 # error WinSock.h has already been included. Define WIN32_LEAN_AND_MEAN in your build, to avoid implicit inclusion of WinSock.h.
47 # endif // defined(_WINSOCKAPI_) && !defined(_WINSOCK2API_)
48 #endif
49 
50 #ifdef _MSC_VER
51 #pragma warning(push)
52 #pragma warning(disable: 4913) // user defined binary operator ',' exists but no overload could convert all operands, default built-in binary operator ',' used
53 #endif
54 
55 #ifdef RCF_USE_BOOST_ASIO
56 #include <boost/asio.hpp>
57 #else
58 #include <RCF/external/asio/asio.hpp>
59 #endif
60 
61 // Do we have local sockets?
62 #ifdef RCF_USE_BOOST_ASIO
63 #ifdef BOOST_ASIO_HAS_LOCAL_SOCKETS
64 #define RCF_HAS_LOCAL_SOCKETS
65 #endif
66 #else
67 #ifdef ASIO_HAS_LOCAL_SOCKETS
68 #define RCF_HAS_LOCAL_SOCKETS
69 #endif
70 #endif
71 
72 #include <RCF/AsioDeadlineTimer.hpp>
73 
74 #ifdef _MSC_VER
75 #pragma warning(pop)
76 #endif
77 
78 namespace RCF {
79 
80 
81  typedef ASIO_NS::ip::tcp::socket AsioSocket;
82  typedef boost::shared_ptr<AsioSocket> AsioSocketPtr;
83 
84  typedef ASIO_NS::const_buffer AsioConstBuffer;
85 
86  typedef AsioSocket TcpSocket;
87  typedef boost::shared_ptr<TcpSocket> TcpSocketPtr;
88 
89 #ifdef RCF_HAS_LOCAL_SOCKETS
90 
91  using ASIO_NS::local::stream_protocol;
92  typedef stream_protocol::socket UnixLocalSocket;
93  typedef boost::shared_ptr<UnixLocalSocket> UnixLocalSocketPtr;
94 
95 #else
96 
97  typedef TcpSocket UnixLocalSocket;
98  typedef TcpSocketPtr UnixLocalSocketPtr;
99 
100 #endif
101 
102 } // namespace RCF
103 
104 #ifdef _MSC_VER
105 #pragma warning(pop)
106 #endif
107 
108 #endif // ! INCLUDE_RCF_ASIO_HPP