RCF is provided as source code, and is intended to be compiled along with the rest of the source code that comprises your application. To compile RCF, you only compile a single file - RCF.cpp
, located in the distribution at src/RCF/RCF.cpp
.
You can compile RCF.cpp
directly into the same module as your own sources, or you can compile it into a static or dynamic library and subsequently link it into your application.
RCF does not have any mandatory dependencies on any other libraries. Previous versions of RCF (2.2 and older) required the Boost header files to be available, but as of RCF 3.0, this is no longer the case.
RCF has several optional dependencies (zlib, OpenSSL, Protocol Buffers), which are enabled through the feature defines listed further down.
Let's assume now that you have downloaded RCF to a directory <rcf_distro>
on your computer.
To build RCF, follow these steps:
<rcf_distro>/include
as an include path.<rcf_distro>/src/RCF/RCF.cpp
.The actual details of compiling and linking will vary depending on the particular compiler you are using.
As an example, let's build the minimal TCP client and server, from the Sample Code section. To get started, create a source file called SampleTcpClientServer.cpp
, and copy-paste the sample code into it. Then follow the instructions below:
New Project -> Visual C++ -> Win32 -> Win32 Console Application
Application Settings
dialog, check the Empty Project
checkbox.Project Properties
dialog for the new project, select C/C++ -> General -> Additional Include Directories
.<rcf_distro>\include
.SampleTcpClientServer.cpp
to the project.<rcf_distro>\src\RCF\RCF.cpp
to the project.Build -> Build Solution
.SampleTcpClientServer.cpp
, run the following command:The example above compiled RCF.cpp
directly into the same C++ module as SampleTcpClientServer.cpp
. You can also compile RCF.cpp
into a static or dynamic library.
RCF.cpp
as usual.RCF_BUILD_DLL
in your build, set any relevant compiler switches for creating dynamic libraries, and compile RCF.cpp
.The following table lists RCF build defines.
Build define | Meaning |
---|---|
RCF_BUILD_DLL | Build a DLL exporting RCF. |
RCF_USE_CUSTOM_ALLOCATOR | Build with custom memory allocator support. |
RCF_USE_CLOCK_MONOTONIC | Use clock_gettime() to implement a monotonic clock. |
RCF_MAX_METHOD_COUNT=<N> | Extends the maximum number of methods allowed in a RCF interface. |
RCF_BUILD_DLL
RCF_BUILD_DLL
needs to be defined when building dynamic libraries. It marks public RCF classes and functions as DLL exports.
RCF_USE_CUSTOM_ALLOCATOR
RCF_USE_CUSTOM_ALLOCATOR
is used to customize memory allocation for network send and receive buffers. If you define RCF_USE_CUSTOM_ALLOCATOR
, you will need to implement the following two functions:
RCF_new()
and RCF_delete()
will be called by RCF whenever allocating or deallocating memory for buffers of data that are being sent or received.
RCF_USE_CLOCK_MONOTONIC
When RCF_USE_CLOCK_MONOTONIC
is defined, RCF will use clock_gettime()
with CLOCK_MONOTONIC
, for internal clock functionality. Otherwise RCF uses gettimefoday()
on POSIX platforms, and GetTickCount()
on Windows platforms.
RCF_MAX_METHOD_COUNT=<N>
By default the maximum number of methods allowed in a RCF interface is 100. This limit can be changed by setting the RCF_MAX_METHOD_COUNT
to a custom value. The maximum allowable value is 200.
RCF comes with a set of feature defines, allowing users to build RCF with a specific set of features.
The following table lists all the available feature defines.
Feature define | RCF feature | Default value |
---|---|---|
RCF_FEATURE_SSPI | Win32 SSPI-based encryption (NTLM, Kerberos, Schannel) | 1 on Windows. 0 otherwise. |
RCF_FEATURE_FILETRANSFER | File transfers | 0 |
RCF_FEATURE_SERVER | Non-critical server-side functionality (server-to-client pingbacks, server objects, session timeouts) | 1 |
RCF_FEATURE_PROXYENDPOINT | Proxy endpoints | 1 |
RCF_FEATURE_PUBSUB | Publish/subscribe | 1 |
RCF_FEATURE_TCP | TCP transports | 1 |
RCF_FEATURE_UDP | UDP transports . | 1 |
RCF_FEATURE_NAMEDPIPE | Win32 named pipe transports | 1 on Windows. 0 otherwise. |
RCF_FEATURE_LOCALSOCKET | Unix local socket transports | 0 on Windows. 1 otherwise. |
RCF_FEATURE_HTTP | HTTP/HTTPS transports | 1 |
RCF_FEATURE_IPV6 | IPv6 support | 1 |
RCF_FEATURE_SF | RCF internal serialization | 1 |
RCF_FEATURE_LEGACY | Backwards compatibility with RCF 1.x and earlier | 0 |
RCF_FEATURE_ZLIB | Zlib-based compression. | 0 |
RCF_FEATURE_OPENSSL | OpenSSL-based SSL encryption. | 0 |
RCF_FEATURE_PROTOBUF | Protocol Buffer support. | 0 |
To use these defines, set them to 0 or 1 depending on whether the feature should be included or not.
For example, to build RCF without HTTP/HTTPS support, define RCF_FEATURE_HTTP=0
in your build.
RCF_FEATURE_FILETRANSFER
The file transfer feature makes use of the standard C++ <filesystem>
library. This library should be available on any compiler supporting the C++17 language update. Note that if you are using gcc or clang, you may need to use the -std=c++17
compiler option to enable C++17 support.
RCF_FEATURE_ZLIB
If you enable this feature by defining RCF_FEATURE_ZLIB=1
, you will need to link to Zlib. It is possible to link statically to Zlib by defining RCF_ZLIB_STATIC
.
RCF_FEATURE_OPENSSL
If you enable this feature by defining RCF_FEATURE_OPENSSL=1
, you will need to link to OpenSSL. It is possible to link statically to OpenSSL by defining RCF_OPENSSL_STATIC
.
RCF_FEATURE_PROTOBUF
If you enable this feature by defining RCF_FEATURE_PROTOBUF=1
, you will need to link to Protocol Buffers.
RCF is written in standard C++ and as such should build on any recent standards-compliant compiler. RCF 3.0 has been tested on the following compilers:
RCF has been tested on Windows and Linux platforms, but you should be able to use it on any of the following :