|
Document of c-modernization-kit (porter) 1.0.0
|
受信テストコマンド。 More...
#include <inttypes.h>#include <signal.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <pthread.h>#include <unistd.h>#include <porter.h>#include <console-util.h>Go to the source code of this file.
Data Structures | |
| struct | BidirSendCtx |
| bidir 送信スレッドに渡すコンテキスト。 More... | |
Typedefs | |
| typedef pthread_t | BidirThread |
Functions | |
| static void | sig_handler (int sig) |
| Linux SIGINT シグナルハンドラー。 | |
| static void | on_recv (int64_t service_id, PotrPeerId peer_id, PotrEvent event, const void *data, size_t len) |
| 受信コールバック関数。 | |
| static int | parse_log_level (const char *str, PotrLogLevel *out) |
| ログレベル文字列を PotrLogLevel に変換する。 | |
| static int | read_line (char *buf, size_t size) |
| 標準入力から1行読み込み、末尾の改行を取り除く。 | |
| static void * | bidir_send_thread_func (void *arg) |
| bidir 送信スレッド関数 (Linux)。 | |
| static int | start_bidir_send_thread (BidirThread *thread, BidirSendCtx *ctx) |
| bidir 送信スレッドを起動する。 | |
| static void | join_bidir_send_thread (BidirThread thread) |
| bidir 送信スレッドの終了を待機して破棄する。 | |
| int | main (int argc, char *argv[]) |
| メインエントリーポイント。 | |
Variables | |
| static volatile int | g_running = 1 |
| 受信ループ継続フラグ。シグナルハンドラーで 0 に設定される。 | |
受信テストコマンド。
指定サービスでデータを受信し続ける CLI テストコマンドです。
Ctrl+C で終了します。
サービス種別が unicast_bidir の場合は双方向モードで動作します。
双方向モードでは受信待機中に標準入力からメッセージを送信できます (空行で送信終了)。
| オプション | 説明 |
|---|---|
| -l <level> | ログレベルを指定します。指定がない場合はログ出力なし。 |
level に指定可能な値: TRACE, DEBUG, INFO, WARN, ERROR, FATAL (大文字小文字不問)
Definition in file recv.c.
| typedef pthread_t BidirThread |
|
static |
|
static |
受信コールバック関数。
| [in] | service_id | サービスの ID。 |
| [in] | peer_id | ピア識別子 (N:1 モード時は非ゼロ、1:1 モード時は 0)。 |
| [in] | event | イベント種別。 |
| [in] | data | 受信データへのポインタ (POTR_EVENT_DATA 時のみ有効)。 |
| [in] | len | 受信データのバイト数 (POTR_EVENT_DATA 時のみ有効)。 |
Definition at line 122 of file recv.c.
References POTR_EVENT_CONNECTED, POTR_EVENT_DATA, POTR_EVENT_DISCONNECTED, and POTR_MAX_PAYLOAD.
Referenced by main().
|
static |
ログレベル文字列を PotrLogLevel に変換する。
| [in] | str | レベル文字列 (TRACE/DEBUG/INFO/WARN/ERROR/FATAL)。 |
| [out] | out | 変換結果の格納先。 |
Definition at line 166 of file recv.c.
References POTR_TRACE_CRITICAL, POTR_TRACE_ERROR, POTR_TRACE_INFO, POTR_TRACE_VERBOSE, and POTR_TRACE_WARNING.
Referenced by main().
|
static |
標準入力から1行読み込み、末尾の改行を取り除く。
| [out] | buf | 読み込み先バッファ。 |
| [in] | size | バッファサイズ (バイト)。 |
Definition at line 217 of file recv.c.
Referenced by bidir_send_thread_func().
|
static |
bidir 送信スレッド関数 (Linux)。
| [in] | arg | BidirSendCtx へのポインタ。 |
Definition at line 237 of file recv.c.
References BidirSendCtx::handle, POTR_MAX_MESSAGE_SIZE, POTR_PEER_NA, POTR_SEND_BLOCKING, POTR_SEND_COMPRESS, POTR_SUCCESS, potrSend(), read_line(), and BidirSendCtx::running.
Referenced by start_bidir_send_thread().
|
static |
bidir 送信スレッドを起動する。
| [out] | thread | スレッドハンドルの格納先。 |
| [in] | ctx | スレッドに渡すコンテキスト。 |
Definition at line 329 of file recv.c.
References bidir_send_thread_func().
Referenced by main().
|
static |
| int main | ( | int | argc, |
| char * | argv[] ) |
メインエントリーポイント。
| [in] | argc | コマンドライン引数の数。 |
| [in] | argv | コマンドライン引数の配列。 |
Definition at line 369 of file recv.c.
References g_running, BidirSendCtx::handle, join_bidir_send_thread(), on_recv(), parse_log_level(), POTR_ROLE_RECEIVER, POTR_SUCCESS, POTR_TRACE_NONE, POTR_TYPE_UNICAST_BIDIR, potrCloseService(), potrGetServiceType(), potrLogConfig(), potrOpenServiceFromConfig(), BidirSendCtx::running, sig_handler(), and start_bidir_send_thread().
|
static |
受信ループ継続フラグ。シグナルハンドラーで 0 に設定される。
Definition at line 58 of file recv.c.
Referenced by main(), sig_handler(), and sig_handler().