您好,
Client Socket设置nonBlocking ,实测用sl_Send调用,比如下面的测试代码,用GPIO测量出来的波形,发现函数没有立刻返回。
GPIO_write(CONFIG_GPIO_STAT1, 0);
int ret = sl_Send(app_CB.imgSock, app_CB.imgSockWData, MAX_BUF_SIZE / 2, 0);
GPIO_write(CONFIG_GPIO_STAT1, 1);
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
您好,
Client Socket设置nonBlocking ,实测用sl_Send调用,比如下面的测试代码,用GPIO测量出来的波形,发现函数没有立刻返回。
您好,
您可以参考如下代码:
GPIO_write(CONFIG_GPIO_STAT1, 0);
// 将套接字设置为非阻塞模式
int nonBlocking = 1;
int status = sl_SetSockOpt(app_CB.imgSock, SL_SOL_SOCKET, SL_SO_NONBLOCKING, &nonBlocking, sizeof(nonBlocking));
if (status < 0) {
// 处理错误
}
// 发送数据
int ret = sl_Send(app_CB.imgSock, app_CB.imgSockWData, MAX_BUF_SIZE / 2, 0);
if (ret < 0) {
if (status == SL_EAGAIN) {
// 套接字是非阻塞的,发送将阻塞
} else {
// 处理错误
}
}
GPIO_write(CONFIG_GPIO_STAT1, 1);
期待您的反馈。