Thrift C++ Software Library
# License
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
# Using Thrift with C++
The Thrift C++ libraries are built using the GNU tools. Follow the instructions
in the top-level README.md
In case you do not want to open another README.md file, do this thrift src:
./bootstrap.sh
./configure (--with-boost=/usr/local)
make
sudo make install
Thrift is divided into two libraries.
* libthrift - The core Thrift library contains all the core Thrift code. It requires
boost shared pointers, pthreads, and librt.
* libthriftnb - This library contains the Thrift nonblocking server, which uses libevent.
To link this library you will also need to link libevent.
## Linking Against Thrift
After you build and install Thrift the libraries are installed to
/usr/local/lib by default. Make sure this is in your LDPATH.
On Linux, the best way to do this is to ensure that /usr/local/lib is in
your /etc/ld.so.conf and then run /sbin/ldconfig.
Depending upon whether you are linking dynamically or statically and how
your build environment it set up, you may need to include additional
libraries when linking against thrift, such as librt and/or libpthread. If
you are using libthriftnb you will also need libevent.
## Dependencies
boost shared pointers
http://www.boost.org/libs/smart_ptr/smart_ptr.htm
libevent (for libthriftnb only)
http://monkey.org/~provos/libevent/
# Using Thrift with C++ on Windows
You need to define an environment variables for 3rd party components separately:
BOOST_ROOT : For boost, e.g. D:\boost_1_55_0
OPENSSL_ROOT_DIR : For OpenSSL, e.g. D:\OpenSSL-Win32
only required by libthriftnb:
LIBEVENT_ROOT_DIR : For Libevent e.g. D:\libevent-2.0.21-stable
See /3rdparty.user for more details.
Thrift is divided into two libraries.
* libthrift - The core Thrift library contains all the core Thrift code. It requires
boost shared pointers, pthreads, and librt.
* libthriftnb - This library contains the Thrift nonblocking server, which uses libevent.
To link this library you will also need to link libevent.
## Linking Against Thrift
You need to link your project that uses thrift against all the thrift
dependencies; in the case of libthrift, boost and for
libthriftnb, libevent.
In the project properties you must also set HAVE_CONFIG_H as force include
the config header: "windows/confg.h"
## Dependencies
boost shared pointers
http://www.boost.org/libs/smart_ptr/smart_ptr.htm
boost thread
http://www.boost.org/doc/libs/release/doc/html/thread.html
libevent (for libthriftnb only)
http://monkey.org/~provos/libevent/
## Notes on boost thread (static vs shared):
By default lib/cpp/windows/force_inc.h defines:
#define BOOST_ALL_NO_LIB 1
#define BOOST_THREAD_NO_LIB 1
This has for effect to have the host application linking against Thrift
to have to link with boost thread as a static library.
If you wanted instead to link with boost thread as a shared library,
you'll need to uncomment those two lines, and recompile.
## Windows version compatibility
The Thrift library targets Windows XP for broadest compatbility. A notable
difference is in the Windows-specific implementation of the socket poll
function. To target Vista, Win7 or other versions, comment out the line
#define TARGET_WIN_XP.
## Named Pipes
Named Pipe transport has been added in the TPipe and TPipeServer classes. This
is currently Windows-only. Named pipe transport for *NIX has not been
implemented. Domain sockets are a better choice for local IPC under non-Windows
OS's. *NIX named pipes only support 1:1 client-server connection.
# Thrift/SSL
## Scope
This SSL only supports blocking mode socket I/O. It can only be used with
TSimpleServer, TThreadedServer, and TThreadPoolServer.
## Implementation
There're two main classes TSSLSocketFactory and TSSLSocket. Instances of
TSSLSocket are always created from TSSLSocketFactory.
PosixSSLThreadFactory creates PosixSSLThread. The only difference from the
PthreadThread type is that it cleanups OpenSSL error queue upon exiting
the thread. Ideally, OpenSSL APIs should only be called from PosixSSLThread.
## How to use SSL APIs
This is for demo. In real code, typically only one TSSLSocketFactory
instance is needed.
shared_ptr<TSSLSocketFactory> getSSLSocketFactory() {
shared_ptr<TSSLSocketFactory> factory(new TSSLSocketFactory());
// client: load trusted certificates
factory->loadTrustedCertificates("my-trusted-ca-certificates.pem");
// client: optionally set your own access manager, otherwise,
// the default client access manager will be loaded.
factory->loadCertificate("my-certificate-signed-by-ca.pem");
factory->loadPrivateKey("my-private-key.pem");
// server: optionally setup access manager
// shared_ptr<AccessManager> accessManager(new MyAccessManager);
// factory->access(accessManager);
...
}
client code sample
shared_ptr<TSSLSocketFactory> factory = getSSLSocketFactory();
shared_ptr<TSocket> socket = factory.createSocket(host, port);
shared_ptr<TBufferedTransport> transport(new TBufferedTransport(socket));
...
server code sample
shared_ptr<TSSLSocketFactory> factory = getSSLSocketFactory();
shared_ptr<TSSLServerSocket> socket(new TSSLServerSocket(port, factory));
shared_ptr<TTransportFactory> transportFactory(new TBufferedTransportFactory));
...
## AccessManager
AccessManager defines a callback interface. It has three callback methods:
(a) Decision verify(const sockaddr_storage& sa);
(b) Decision verify(const string& host, const char* name, int size);
(c) Decision verify(const sockaddr_storage& sa, const char* data, int size);
After SSL handshake completes, additional checks are conducted. Application
is given the chance to decide whether or not to continue the conversation
with the remote. Application is queried through the above three "verify"
method. They are called at different points of the verification process.
Decisions can be one of ALLOW, DENY, and SKIP. ALLOW and DENY means the
conversation should be continued or disconnected, respectively. ALLOW and
DENY decision stops the verification process. SKIP means there's no decision
based on the given input, continue the verification process.
First, (a) is called with the remote IP. It is called once at the beginning.
"sa" is the IP address of the remote peer.
Then, the certificate of remote peer is loaded. SubjectAltName extensions
are extracted and sent to application for verification. When a DNS
subjectAltName field is extracted, (b) is called. When an IP subjectAltName
field is extracted, (c) is called.
The "host" in (b) is the value from TSocket::getHost() if this is a client
side socket, or TSocket::getPeerHost() if this is a server side socket. The
reason is client side socket initiates the connection. TSocket::getHost()
is the remote host name. On server side, the remote host name is unknown
unless it's retrieved through TSocket::getPeerHost(). Either way, "host"
should be the remote host name. Keep in mind, if TSocket::getPeerHost()
failed, it would return the remote host name in numeric format.
If all subjectAltName extensions were "skipped", the common name field would
be checked. It
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
thrift 0.9.3 for vs2013/vs2015 直接打开 thrift-master-0.9.3\lib\cppVS2013\thrift.sln thrift-master-0.9.3\lib\cppVS2015\thrift.sln 编译即可
资源推荐
资源详情
资源评论
收起资源包目录
thrift-master-0.9.3-for-vs2013-vs2015 (2000个子文件)
_oasis 793B
_oasis 553B
configure.ac 29KB
configure.ac 5KB
Makefile.am 16KB
Makefile.am 13KB
Makefile.am 13KB
Makefile.am 9KB
Makefile.am 9KB
Makefile.am 8KB
Makefile.am 6KB
Makefile.am 5KB
Makefile.am 5KB
Makefile.am 4KB
Makefile.am 4KB
Makefile.am 4KB
Makefile.am 3KB
Makefile.am 3KB
Makefile.am 3KB
Makefile.am 3KB
Makefile.am 3KB
Makefile.am 3KB
Makefile.am 3KB
Makefile.am 3KB
Makefile.am 3KB
Makefile.am 2KB
Makefile.am 2KB
Makefile.am 2KB
Makefile.am 2KB
Makefile.am 2KB
Makefile.am 2KB
Makefile.am 2KB
Makefile.am 2KB
Makefile.am 2KB
Makefile.am 2KB
Makefile.am 2KB
Makefile.am 2KB
Makefile.am 2KB
Makefile.am 2KB
Makefile.am 2KB
Makefile.am 2KB
Makefile.am 2KB
Makefile.am 2KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 999B
Makefile.am 970B
Makefile.am 970B
Makefile.am 968B
Makefile.am 958B
Makefile.am 917B
Makefile.am 916B
Makefile.am 915B
Makefile.am 862B
Makefile.am 839B
TBinaryProtocol.as 8KB
TFullDuplexHttpClient.as 8KB
TSocket.as 5KB
CalculatorUI.as 5KB
TProtocolUtil.as 5KB
THttpClient.as 4KB
TTransport.as 4KB
TApplicationError.as 3KB
TProtocol.as 3KB
Set.as 2KB
TBase.as 2KB
FieldMetaData.as 2KB
TType.as 1KB
TProtocolError.as 1KB
FieldValueMetaData.as 1KB
TMessage.as 1KB
TField.as 1KB
TTransportError.as 1KB
MapMetaData.as 1KB
TProcessor.as 1KB
ListMetaData.as 1KB
SetMetaData.as 1KB
TMap.as 1KB
AbstractMethodError.as 1KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
- m0_380357522018-12-07运行不成功。
- icedemonbaby2017-11-14下来试试看
- huabinzhang2018-03-16下来试试看
- gqz1234562017-08-25最新版本好像已经到0.10.0了
jnpher
- 粉丝: 210
- 资源: 44
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功