建链
功能介绍
调用Connect接口向Server侧建立通信链路,链路主要用于内存的传输,其中P/D均可作为Server或者Client,按需设置。
使用场景
建链操作是节点之间进行数据传输的前提,建链接口采用类TCP建链流程,Server初始化时提供侦听信息,由Client侧发起建链。
功能示例
初始化AdxlEngine。其中Server侧需要设置侦听的Host IP和port。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
// Server侧 AdxlEngine engine; std::map<AscendString, AscendString> options; AscendString local_engine = "ip:port"; // 替换成真实IP端口;是AdxlEngine的唯一标识,端口为有效值 auto ret = engine.Initialize(local_engine, options); if (ret != SUCCESS) { printf("[ERROR] Initialize failed, ret = %u\n", ret); return -1; } // Client侧 AdxlEngine engine; std::map<AscendString, AscendString> options; AscendString local_engine = "ip:port"; // 替换成真实IP;是AdxlEngine的唯一标识,端口可不设置或设置为负数,此时表示不侦听 auto ret = engine.Initialize(local_engine, options); if (ret != SUCCESS) { printf("[ERROR] Initialize failed, ret = %u\n", ret); return -1; } |
在Client侧调用Connect发起建链操作。
1 2 3 4 5 6 |
AscendString remote_engine = "ip:port"; // 替换成需要与之建链的Server的local engine auto ret = engine.Connect(remote_engine); if (ret != SUCCESS) { printf("[ERROR] Connect failed, ret = %u\n", ret); return -1; } |
父主题: 链路管理