|
Document of c-modernization-kit (porter) 1.0.0
|
TCP サーバーサンプル共通実装。 More...
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <console-util.h>#include "tcpServer.h"Go to the source code of this file.
Functions | |
| void | handle_client_session (ClientFd fd) |
| TCP 通信メインループ (デフォルト実装)。 | |
| static void | parse_args (int argc, char *argv[], ServerMode *mode, int *port, int *workers, int *conns_per_worker) |
| コマンドライン引数を解析します。 | |
| int | main (int argc, char *argv[]) |
| メインエントリーポイント。 | |
TCP サーバーサンプル共通実装。
プラットフォーム共通の処理を実装します。
プラットフォーム差異は tcpServer.h のマクロ (ClientFd / client_recv / client_send / client_close / get_pid) および各プラットフォームファイルが実装するフック関数 (platform_init / platform_cleanup / dispatch_internal_args) で吸収します。
Definition in file tcpServer.c.
| void handle_client_session | ( | ClientFd | fd | ) |
TCP 通信メインループ (デフォルト実装)。
| [in] | fd | クライアントソケット。 |
受信したデータをそのまま返します。クライアントが切断すると戻ります。 ソケットは本関数内で閉じます。fork モード・prefork モード共用。
Definition at line 34 of file tcpServer.c.
References BUFFER_SIZE, client_close, client_recv, client_send, and get_pid.
Referenced by main().
|
static |
コマンドライン引数を解析します。
| [in] | argc | 引数の数。 |
| [in] | argv | 引数の配列。 |
| [out] | mode | 動作モード (MODE_FORK / MODE_PREFORK)。 |
| [out] | port | 待ち受けポート番号。 |
| [out] | workers | ワーカー数。 |
| [out] | conns_per_worker | 1 ワーカーあたりの同時接続数。 |
--mode fork|prefork / --port <num> / --workers <num> / --conns-per-worker <num> を解析します。 内部起動引数 (--child, --worker) は dispatch_internal_args() で処理済みの ため、本関数では無視します。
Definition at line 66 of file tcpServer.c.
References MODE_FORK, and MODE_PREFORK.
Referenced by main().
| int main | ( | int | argc, |
| char * | argv[] ) |
メインエントリーポイント。
| [in] | argc | コマンドライン引数の数。 |
| [in] | argv | コマンドライン引数の配列。 |
Definition at line 101 of file tcpServer.c.
References DEFAULT_CONNS_PER_WORKER, DEFAULT_PORT, DEFAULT_WORKERS, dispatch_internal_args(), handle_client_session(), MODE_FORK, MODE_PREFORK, parse_args(), platform_cleanup(), platform_init(), run_fork_server(), and run_prefork_server().