A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/laocai/tcp-nginx-module below:

laocai/tcp-nginx-module: Use nginx as a common TCP server framework

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”

Develop Command Protocol Server
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

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4