# NATS & NATS Streaming - C Client
A C client for the [NATS messaging system](https://nats.io).
Go [here](http://nats-io.github.io/nats.c) for the online documentation,
and check the [frequently asked questions](https://github.com/nats-io/nats.c#faq).
This NATS Client implementation is heavily based on the [NATS GO Client](https://github.com/nats-io/nats.go). There is support for Mac OS/X, Linux and Windows (although we don't have specific platform support matrix).
[![License Apache 2](https://img.shields.io/badge/License-Apache2-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)
[![Build Status](https://travis-ci.com/nats-io/nats.c.svg?branch=main)](https://travis-ci.com/github/nats-io/nats.c)
[![Coverage Status](https://coveralls.io/repos/github/nats-io/nats.c/badge.svg?branch=main)](https://coveralls.io/github/nats-io/nats.c?branch=main)
[![Release](https://img.shields.io/badge/release-v3.8.2-blue.svg?style=flat)](https://github.com/nats-io/nats.c/releases/tag/v3.8.2)
[![Documentation](https://img.shields.io/badge/doc-Doxygen-brightgreen.svg?style=flat)](http://nats-io.github.io/nats.c)
# Table of Contents
- [Installing](#installing)
- [Building](#building)
* [TLS Support](#tls-support)
* [Link statically](#link-statically)
* [Building with Streaming](#building-with-streaming)
* [Building with Libsodium](#building-with-libsodium)
* [Testing](#testing)
- [Documentation](#documentation)
- [NATS Client](#nats-client)
* [Important Changes](#important-changes)
* [JetStream](#jetstream)
* [JetStream Basic Usage](#jetstream-basic-usage)
* [JetStream Basic Management](#jetstream-basic-usage)
* [KeyValue](#keyvalue)
* [KeyValue Management](#keyvalue-management)
* [KeyValue APIs](#keyvalue-apis)
* [Getting Started](#getting-started)
* [Basic Usage](#basic-usage)
* [Headers](#headers)
* [Wildcard Subscriptions](#wildcard-subscriptions)
* [Queue Groups](#queue-groups)
* [TLS](#tls)
* [New Authentication (Nkeys and User Credentials)](#new-authentication-nkeys-and-user-credentials)
* [Advanced Usage](#advanced-usage)
* [Clustered Usage](#clustered-usage)
* [Using an Event Loop Library](#using-an-event-loop-library)
* [FAQ](#faq)
- [NATS Streaming Client](#nats-streaming-client)
* [Streaming Basic Usage](#streaming-basic-usage)
* [Streaming Subscriptions](#streaming-subscriptions)
* [Streaming Durable Subscriptions](#streaming-durable-subscriptions)
* [Streaming Queue Groups](#streaming-queue-groups)
* [Creating a Queue Group](#creating-a-queue-group)
* [Start Position](#start-position)
* [Leaving the Group](#leaving-the-group)
* [Closing a Queue Group](#closing-a-queue-group)
* [Streaming Durable Queue Groups](#streaming-durable-queue-groups)
* [Creating a Durable Queue Group](#creating-a-durable-queue-group)
* [Start Position of the Durable Queue Group](#start-position-of-the-durable-queue-group)
* [Leaving the Durable Queue Group](#leaving-the-durable-queue-group)
* [Closing the Durable Queue Group](#closing-the-durable-queue-group)
* [Streaming Wildcard Subscriptions](#streaming-wildcard-subscriptions)
* [Streaming Advanced Usage](#streaming-advanced-usage)
* [Connection Status](#connection-status)
* [Asynchronous Publishing](#asynchronous-publishing)
* [Message Acknowledgments and Redelivery](#message-acknowledgments-and-redelivery)
* [Rate limiting/matching](#rate-limitingmatching)
* [Publisher Rate Limiting](#publisher-rate-limiting)
* [Subscriber Rate Limiting](#subscriber-rate-limiting)
- [License](#license)
## Installing
There are several package managers with NATS C client library available. If you know one that is not in this list, please submit a PR to add it!
- [conan](https://conan.io/center) The "cnats" recipe is [here](https://github.com/conan-io/conan-center-index/tree/master/recipes/cnats)
- [Homebrew](https://github.com/Homebrew/homebrew-core) The "cnats" formula is [here](https://github.com/Homebrew/homebrew-core/blob/master/Formula/c/cnats.rb)
- [vcpkg](https://vcpkg.io) The "cnats" port is [here](https://github.com/microsoft/vcpkg/tree/master/ports/cnats)
## Building
First, download the source code:
```
git clone git@github.com:nats-io/nats.c.git .
```
To build the library, use [CMake](https://cmake.org/download/). Note that by default the NATS Streaming API will be built and included in the NATS library.
See below if you do not want to build the Streaming related APIs.
Make sure that CMake is added to your path. If building on Windows, open a command shell from the Visual Studio Tools menu, and select the appropriate command shell (x64 or x86 for 64 or 32 bit builds respectively). You will also probably need to run this with administrator privileges.
Create a `build` directory (any name would work) from the root source tree, and `cd` into it. Then issue this command for the first time:
```
cmake ..
```
In some architectures, you may experience a compilation error for `mutex.c.o` because there is no support
for the assembler instruction that we use to yield when spinning trying to acquire a lock.
You may get this sort of build error:
```
/tmp/cc1Yp7sD.s: Assembler messages:
/tmp/cc1Yp7sD.s:302: Error: selected processor does not support ARM mode `yield'
src/CMakeFiles/nats_static.dir/build.make:542: recipe for target 'src/CMakeFiles/nats_static.dir/unix/mutex.c.o' failed
```
If that's the case, you can solve this by enabling the `NATS_BUILD_NO_SPIN` flag (or use `-DNATS_NO_SPIN` if you compile without CMake):
```
cmake .. -DNATS_BUILD_NO_SPIN=ON
```
If you had previously built the library, you may need to do a `make clean`, or simply delete and re-create the build directory before executing the cmake command.
To build on Windows, you would need to select the build generator. For instance, to select `nmake`, you would run:
```
cmake .. -G "NMake Makefiles"
```
Running `cmake -h` would give you the list of possible options and all the generator names.
Alternatively, you can run the GUI version. From that same *build* command shell, start the GUI:
```
c:\program files (x86)\CMake\bin\cmake-gui.exe
```
If you started with an empty build directory, you would need to select the source and build directory, then click `Configure`. Here, you will be able to select from the drop-down box the name of the build generator. When done, click `Generate`. Then you can go back to your command shell, or Visual Studio and build.
To modify some of the build options, you need to edit the cache and rebuild.
```
make edit_cache
```
Note that if you build on Windows and have selected "NMake Makefiles", replace all following references to `make` with `nmake`.
Editing the cache allows you to select the build type (Debug, Release, etc), the architecture (64 or 32bit), and so on.
The default target will build everything, that is, the static and shared NATS libraries and also the examples and the test program. Each are located in their respective directories under your build directory: `src`, `examples` and `test`.
```
make install
```
Will copy both the static and shared libraries in the folder `install/lib` and the public headers in `install/include`.
## TLS Support
By default, the library is built with TLS support. You can disable this from the cmake gui `make edit_cache` and switch the `NATS_BUILD_WITH_TLS` option to `OFF`, or pass the option directly to the `cmake` command:
```
cmake .. -DNATS_BUILD_WITH_TLS=OFF
```
Starting `2.0.0`, when building with TLS/SSL support, the server certificate's expected hostname is always verified. It means that the hostname provided in the URL(s) or through the option `natsOptions_SetExpectedHostname()` will be used to check the hostname present in the certificate. Prior to `2.0.0`, the hostname would be verified *only* if the option `natsOptions_SetExpectedHostname()` was invoked.
Although we recommend leaving the new default behavior, you can restore the previous
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
nats.c-main.zip (736个子文件)
test.c 1.11MB
jsm.c 126KB
conn.c 120KB
js.c 99KB
util.c 69KB
protocol.pb-c.c 48KB
opts.c 40KB
kv.c 39KB
sub.c 39KB
parser.c 28KB
conn.c 26KB
msg.c 25KB
micro.c 23KB
sub.c 20KB
comsock.c 19KB
hash.c 19KB
pub.c 18KB
pub.c 17KB
bench_sub_async.c 13KB
srvpool.c 13KB
glib.c 12KB
crypto.c 12KB
nats.c 12KB
micro_endpoint.c 11KB
micro_monitoring.c 11KB
glib_last_error.c 8KB
glib_timer.c 8KB
sub.c 7KB
micro-func.c 7KB
js-sub.c 7KB
nuid.c 6KB
copts.c 6KB
js-pub.c 6KB
micro-sequence.c 6KB
url.c 6KB
buf.c 5KB
micro_request.c 5KB
micro_error.c 5KB
connect.c 5KB
nkeys.c 5KB
glib_dispatch_pool.c 5KB
sopts.c 5KB
replier.c 5KB
micro-arithmetics.c 5KB
micro-stats.c 4KB
pub.c 4KB
thread.c 4KB
headers.c 4KB
queuegroup.c 4KB
glib_async_cb.c 4KB
subscriber.c 4KB
libevent-pub.c 4KB
pub-async.c 4KB
sock.c 4KB
libuv-sub.c 4KB
libuv-pub.c 4KB
thread.c 4KB
libevent-sub.c 3KB
glib_gc.c 3KB
strings.c 3KB
asynctimeout.c 3KB
mutex.c 3KB
msg.c 3KB
asynccb.c 3KB
sock.c 3KB
cond.c 3KB
micro-hello.c 3KB
cond.c 2KB
requestor.c 2KB
natstime.c 2KB
dispatch.c 2KB
replier.c 2KB
timer.c 2KB
asyncsub.c 2KB
syncsub.c 2KB
publisher.c 2KB
glib_ssl.c 2KB
micro_client.c 2KB
requestor.c 2KB
stats.c 2KB
status.c 2KB
pubmsg.c 2KB
mutex.c 1KB
pubbytes.c 1KB
pubstr.c 1KB
nonats.c 942B
DoxyFile.NATS.Client 117KB
tlsverify.conf 346B
tlsfirst.conf 294B
tls_noip.conf 233B
tls_default_port.conf 228B
tls.conf 228B
permissions.conf 143B
customdoxygen.css 26KB
customdoxygen.css 26KB
tabs.css 8KB
search.css 4KB
navtree.css 2KB
.gitignore 290B
diffstat_sub_async.go 4KB
共 736 条
- 1
- 2
- 3
- 4
- 5
- 6
- 8
资源评论
相由心生901
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- android-studio-2024.2.1.10-mac-arm.zip.002
- MATLAB的车牌识别实现车牌定位面板.zip
- MATLAB打地鼠游戏代码源码.zip
- 基于Django+vue3+mysql前后分离的疫情数据数据进行动态可视化源码+文档说明(Python毕设)
- springboot校内跑腿业务系统(springboot+vue+mysql+说明文档).zip
- android-studio-2024.2.1.10-mac.zip.002
- android-studio-2024.2.1.10-mac.zip.001
- C语言ringbuffer
- 机器学习(预测模型):森林健康和生态多样性的一个综合数据集
- springboot基于web的二手闲置交易系统(springboot+vue+mysql+说明文档).zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功