停止服务端 - TcpServerStop
函数简介
停止TCP服务端(会断开所有连接)。
接口名称
TcpServerStop
DLL调用
int32_t TcpServerStop(int64_t instance, int64_t server_handle);
参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| instance | 长整数型 | OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。 |
| server_handle | 长整数型 | 服务端句柄 |
示例
// 停止服务端
int32_t result = TcpServerStop(instance, server);
if (result == 1) {
printf("服务端已停止\n");
}
// 停止后销毁
TcpServerStop(instance, server);
TcpServerDestroy(instance, server);
返回值
整数型,1 成功,0 失败。
注意事项
- 停止后会断开所有客户端连接
- 每个连接断开都会触发回调(event_type=2)
- 停止后不再接受新连接
- 建议在程序退出前停止服务端
