-
This framework processes details of net sockets.With it, you can be focus on the busines logics and do not care the issues of sockets and concurrences. You just need to define some interfaces to deal with the business logics and add it to plugins, then run the framework.
-
Define: INT32 TcpHandleInit(const CHAR * file);
-
This interface initializes some resources for tcp handler. The parameter 'file' supports the path of configure file.
-
Define: INT32 TcpHandlerConnected(INT32 sock_fd, const CHAR * ip, INT32 port);
-
This interface is called by frameworks when a socket connection is created.You can do some logical check for the connection. For example: You can verify the connection. If the connection is invalid, the function returns non-zero, then the framework will disconnect.
-
Define: INT32 TcpHandlerDisconnected(INT32 sock_fd, const CHAR * ip, INT32 port);
-
This interface is called by frameworks when a socket is disconnected,You can set free resources that have been allocated by TcpHandlerConnected.
-
Define: INT32 FinishTcpHandle();
-
This interface is called by frameworks when the AP is shutdown gracefully.You can set free resources that have been allocated by TcpHandleInit.
-
Define: INT32 MsgHandleUnpack(const CHAR * data, INT32 size);
-
This interface helps you to split package into multiple datagrams.The return value indicates the length of one datagram.
-
Define: INT32 MsgHandleRoute(const CHAR * data, INT32 size);
-
This interface makes the load banlance of JOBs, the return value indicates the ID of one JOB.
-
Define: INT32 MsgHandleInit(const CHAR * file);
-
This interface is called by frameworks when a job is initialized.You can allocate resources here.
-
Define: INT32 MsgHandleProcessing(const CHAR * data, INT32 size, CHAR * out, INT32 * out_size, AsyncCallBackWrite func, VOID * params, INT32 params_size);
-
This interface is the main entry of the business logics.You can implement it synchronous and asynchronous.It returns zero that indicates success, and non-zero indicates failure.
-
Define: INT32 MsgHandleFinish();
-
This interface is called by frameworks when a JOB is shutdown gracefully.You can set free resources allocated by MsgHandleInit.
libcurl: https://curl.haxx.se/
-
wget https://curl.haxx.se/download/curl-7.56.1.tar.gz tar zxvf curl-7.56.1.tar.gz cd curl-7.56.1 ./configure make sudo make install
-
git clone --recursive https://github.com/changyuezhou/net_framework.git OPTION: comment line 'add_subdirectory(db)' in net_framework/commlib/CMakeLists.txt mkdir build cd build cmake ../net_framework make
-
${NET_FRAMWORK_DIR}/install/install.sh NSF [REQUIRED HOME_DIR] [REQUIRED LOG_DIR] HOME_DIR: framework install dir LOG_DIR: log dir
-
${NET_FRAMWORK_DIR}/install/install.sh PLUGIN [REQUIRED HOME_DIR] [REQUIRED LOG_DIR] [REQUIRES PLUGIN_LIB] [OPTION: PLUGIN_ETC] HOME_DIR: framework install dir LOG_DIR: log dir PLUGIN_LIB: path of plugin lib PLUGIN_ETC: path of plugin config file
-
${NET_FRAMWORK_DIR}/install/install.sh ALL [REQUIRED HOME_DIR] [REQUIRED LOG_DIR] [REQUIRES PLUGIN_LIB] [OPTION: PLUGIN_ETC] HOME_DIR: framework install dir LOG_DIR: log dir PLUGIN_LIB: path of plugin lib PLUGIN_ETC: path of plugin config file
-
${HOME_DIR} | |--etc--{ap.conf, ctrl.conf, job.conf} |--bin--{nsf_ctrl, nsf_ap, nsf_job} |--plugins | |--libs--{${PLUGIN_LIB}} |--etc--{${PLUGIN_ETC}}
-
see: https://github.com/changyuezhou/net_framework/tree/master/etc
-
Do something you like :-) ...............
-
${HOME_DIR}/bin/service.sh START
-
${HOME_DIR}/bin/service.sh STOP