销毁客户端 - TcpClientDestroy
函数简介
销毁TCP客户端(会自动断开连接)。
接口名称
TcpClientDestroy
DLL调用
int32_t TcpClientDestroy(int64_t instance, int64_t client_handle);
参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| instance | 长整数型 | OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。 |
| client_handle | 长整数型 | 客户端句柄 |
示例
// 创建客户端
int64_t client = TcpClientCreate(instance, OnTcpClientEvent, 0, 1);
TcpClientConnect(instance, client, "127.0.0.1", 8080);
// 使用完毕后销毁
int32_t result = TcpClientDestroy(instance, client);
if (result == 1) {
printf("客户端已销毁\n");
}
返回值
整数型,1 成功,0 失败。
注意事项
- 销毁前会自动断开连接
- 销毁后,客户端句柄失效,不可再使用
- 销毁会释放所有相关资源
- 建议在程序退出前销毁所有客户端
- 销毁后不会再触发回调
