wolfSSL_get_error错误码-397

在使用WolfSSL时遇到读数据错误,错误码为-397,问题源于局域网内设备IP重复。本文记录了该问题及解决思路。

记录:

使用wolfssl时遇到wolfSSL_read读数据错误,wolfSSL_get_error得到错误码为-397。

同一个局域网下,设备的ip和另一个设备的ip重复导致。

static int hub_http_client_dataProcess(TCP_CONNECTION_T * connection) { int s32Len = 0; HUB_CLIENT_HTTP_CTX *session = connection->param; if (!connection || !session) { HUB_MANAGE_ERROR("http_client recv data failed.\n"); return ERROR; } HUB_HTTP_RESP_MESSAGE_S *stRsp = &session->rspMsg; uint8_t buf[HTTP_READ_MESSAGE_LEN] = {0}; /* 读取数据并缓存 */ do { s32Len = tcp_read_data(connection, (char *)buf, HTTP_READ_MESSAGE_LEN); if (s32Len <= 0 && s32Len != TPSSL_ERROR_WANT_READ) { HUB_MANAGE_ERROR("http_client read data failed, ret %d.\n", s32Len); goto ssl_exit; } if (s32Len > 0) { int err = http_recv_data_handle(session, buf, s32Len); if (err) { goto ssl_exit; } } } while (s32Len == HTTP_READ_MESSAGE_LEN); return OK; ssl_exit: hub_http_message_clean(&session->rspMsg); session->cb(session, HTTP_EVENT_ERROR, stRsp); return ERROR; }S32 tcp_read_data(TCP_CONNECTION_T *conn, char *buf, int buf_len) { S32 ret = -1; if ((NULL == conn) || (NULL == buf) || (0 >= buf_len)) { return ERROR; } if (TRUE == conn->use_ssl) { ret = tpssl_RecvData(conn->ssl, buf, buf_len, 0); } else { ret = recv(conn->sock, buf, buf_len, 0); } return ret; }int tpssl_RecvData(void *ssl, char *buf, int buf_len, int try_times) { int ret = -1; if ((NULL == ssl) || (NULL == buf) || (0 >= buf_len) || (0 >= try_times)) { return ERROR; } CYASSL *pssl = (CYASSL *)ssl; do { ret = SSLRead(pssl, buf, buf_len); if (0 < ret) { break; } usleep(1000); try_times--; }while(try_times > 0); return ret; }CYASSL_API int SSLRead(CYASSL*, void*, int); 为啥会[HUB_MANAGE]http_client read data failed, ret -30848?
最新发布
10-12
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值