概述:
之前下载并安装了nanomsg库,接下来就是看看怎么使用啦。首先是看看如何实现进程间的通信吧。
实例demo:
#include <stdio.h>
#include <pthread.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <nanomsg/pair.h>
#include <nanomsg/bus.h>
#include <nanomsg/nn.h>
/*
PAIR - simple one-to-one communication
BUS - simple many-to-many communication
REQREP - allows to build clusters of stateless services to process user requests
PUBSUB - distributes messages to large sets of interested subscribers
PIPELINE - aggregates messages from multiple sources and load balances them among many destinations
SURVEY - allows to query state of multiple applications in a single go
*/
/*
INPROC - transport within a process (between threads, modules etc.) 线程
IPC - transport between processes on a single machine 进程
TCP - network transport via TCP 网络TCP
WS - websockets over TCP websockets