代码拉取完成,页面将自动刷新
Use nginx as a common TCP server framework
The motivation for writing these is to use nginx as a common TCP server framework, So it called ngxtcp.The ngxtcp.jpg illustrates this framework.Most of the code is modificationed from nginx mail modules.I developed an application protocol that is named command protocol over the TCP.
Command Protocol Format
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| size |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| cmd |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| spare0 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| spare1 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| spare2 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| spare3 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| spare4 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| spare5 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| body |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Command Protocol Header Filed “size == head + body”
example in the ping_pong dir
tcp {
max_socketfd_value 100000;
worker_process_unix_listen logs/tcp;
# keys_zone size must >= (max_socketfd_value * 16 + worker_processes * 512)
socketfd_shm /tmp/socketfd_shm keys_zone=cache_socketfd_shm:10m;
max_pkg_size 2m;
# error_log logs/tcp_err.log debug;
server {
timeout 240;
protocol cmd;
listen 9190;
}
}
Download the latest stable version of the release tarball of this module
from github ()
Grab the nginx source code from nginx.org (<http://nginx.org/>), extract the source and go into the dir.
# ./configure --prefix=/path/to/$build_prefix --add-module=/path/to/tcp_module
# make
# make install
# mkdir /path/to/$build_prefix/cmdso
# cd /path/to/tcp_module/ping_pong
# make
# cp /path/to/tcp_module/ping_pong/svr/pp.so /path/to/$build_prefix/cmdso/
# cd /path/to/$build_prefix/sbin/
# ./nginx
# cd /path/to/tcp_module/ping_pong/cli/
# ./pp_cmd_cli
* How to support nginx reload in ngx_tcp
* Only support linux
1. test ssl
2. exploit more nginx/ngx_tcp to develop Command Protocol Shared Dynamic Library, for example shared memory and so on.
3. add doc or blob
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。