网站规划的基本内容有哪些十大经典口碑营销案例
1. 本程序功能
1) 要有完整的request 和 response;
2) 支持多进程并行处理任务;
3)子进程任务结束后无僵尸进程
2.Apache Thrift C++库的编译和安装
见
步步详解:Apache Thrift C++库从编译到工作模式DEMO_北雨南萍的博客-CSDN博客
3.框架生成
数据字段定义:
cat Datainfo.thrift
# Datainfo.thrift
struct message
{
1:i32 seqId,
2:string content
}
struct response
{
1:i32 seqId,
2:string content
}
service serDemo
{
response put(1:message msg)
}
thrift -gen cpp Datainfo.thrift
4.Server端源码
serDemo_server.skeleton.cpp
// This autogenerated skeleton file illustrates how to build a server.
// You should copy it to another filename to avoid overwriting it.#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>#include <iostream>
#include <stdexcept>
#include <thread>#include "serDemo.h"#include <thrift/concurrency/ThreadManager.h>
#include <thrift/concurrency/ThreadFactory.h>
#include <thr