|
Document of c-modernization-kit (porter) 1.0.0
|
potrSend 関数の実装。 More...
#include <stdlib.h>#include <inttypes.h>#include <porter_const.h>#include <porter.h>#include "../potrContext.h"#include "../potrPeerTable.h"#include "../infra/potrSendQueue.h"#include "../infra/compress/compress.h"#include "../infra/potrLog.h"#include <pthread.h>Go to the source code of this file.
Macros | |
| #define | POTR_MUTEX_LOCK_LOCAL(m) |
| #define | POTR_MUTEX_UNLOCK_LOCAL(m) |
Functions | |
| static int | send_to_peer (struct PotrContext_ *ctx, PotrPeerId peer_id, const uint8_t *ptr, size_t len, int flags, uint16_t base_flags) |
| POTR_EXPORT int POTR_API | potrSend (PotrHandle handle, PotrPeerId peer_id, const void *data, size_t len, int flags) |
| メッセージを送信します。 | |
potrSend 関数の実装。
Definition in file potrSend.c.
| #define POTR_MUTEX_LOCK_LOCAL | ( | m | ) |
| #define POTR_MUTEX_UNLOCK_LOCAL | ( | m | ) |
|
static |
Definition at line 39 of file potrSend.c.
References PotrServiceDef::encrypt_enabled, PotrContext_::global, PotrGlobalConfig::max_payload, POTR_CRYPTO_TAG_SIZE, POTR_ERROR, POTR_FLAG_MORE_FRAG, POTR_PAYLOAD_ELEM_HDR_SIZE, POTR_SEND_BLOCKING, potr_send_queue_push_wait(), potr_send_queue_wait_drained(), POTR_SUCCESS, PotrContext_::send_queue, PotrContext_::send_thread_running, and PotrContext_::service.
Referenced by potrSend().
| POTR_EXPORT int POTR_API potrSend | ( | PotrHandle | handle, |
| PotrPeerId | peer_id, | ||
| const void * | data, | ||
| size_t | len, | ||
| int | flags ) |
メッセージを送信します。
| [in] | handle | potrOpenService() で取得したセッションハンドル。 |
| [in] | peer_id | 送信先ピア識別子。 N:1 モード: 有効なピア ID (POTR_PEER_NA / POTR_PEER_ALL 以外) を指定します。 N:1 モード: POTR_PEER_ALL を指定すると全接続ピアへ一斉送信します。 N:1 モード: POTR_PEER_NA を指定すると POTR_ERROR を返します。 1:1 モードおよびその他の通信種別: POTR_PEER_NA または POTR_PEER_ALL を指定します (通常は POTR_PEER_NA を使用)。 |
| [in] | data | 送信するメッセージへのポインタ。 |
| [in] | len | 送信するメッセージのバイト数。 |
| [in] | flags | 送信オプションフラグ。以下のフラグを論理和で組み合わせて指定します。 0 を指定すると非圧縮・ノンブロッキング送信になります。 |
| フラグ | 説明 |
|---|---|
| POTR_SEND_COMPRESS | メッセージを圧縮して送信します。 |
| POTR_SEND_BLOCKING | ブロッキング送信を行います。 |
通信種別に応じて以下の宛先へ UDP パケットを送信します。
| 通信種別 | 送信先 |
|---|---|
| POTR_TYPE_UNICAST | 接続相手の dst_port 宛にユニキャスト送信 |
| POTR_TYPE_MULTICAST | multicast_group:dst_port へ送信 |
| POTR_TYPE_BROADCAST | broadcast_addr:dst_port へ送信 |
| POTR_TYPE_UNICAST_BIDIR (N:1) | peer_id で指定したピアへ送信 |
compress に POTR_SEND_COMPRESS を指定した場合、内部で圧縮処理を行ってから送信します。
圧縮後のサイズが元のサイズ以上になった場合は、自動的に非圧縮で送信します。
受信側の PotrRecvCallback には、解凍済みの元メッセージが渡されます。
送受信ともにフラグメント化と組み合わせて使用できます。
Definition at line 88 of file potrSend.c.
References PotrPeerContext_::active, PotrContext_::compress_buf, PotrContext_::compress_buf_size, PotrContext_::global, PotrContext_::is_multi_peer, PotrGlobalConfig::max_message_size, PotrContext_::max_peers, peer_find_by_id(), PotrPeerContext_::peer_id, PotrContext_::peers, PotrContext_::peers_mutex, POTR_API, potr_compress(), POTR_ERROR, POTR_ERROR_DISCONNECTED, POTR_EXPORT, POTR_FLAG_COMPRESSED, potr_is_raw_type(), potr_is_tcp_type(), POTR_LOG, POTR_MUTEX_LOCK_LOCAL, POTR_MUTEX_UNLOCK_LOCAL, POTR_PEER_ALL, POTR_PEER_NA, POTR_SEND_BLOCKING, POTR_SEND_COMPRESS, POTR_SUCCESS, POTR_TRACE_ERROR, POTR_TRACE_VERBOSE, send_to_peer(), PotrContext_::service, PotrServiceDef::service_id, PotrContext_::tcp_active_paths, and PotrServiceDef::type.
Referenced by bidir_send_thread_func(), and main().