完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
void Propulsiontask(void const * argument){ /* USER CODE BEGIN Propulsiontask */ /* Infinite loop */ struct sockaddr_in server_addr_push; struct sockaddr_in connect_addr_push; int socket_push; int socket_connect_push; socklen_t addr_len; int err; int recv_push = 0; int send_push = 0; unsigned char data_buffer_push[50]; socket_push = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if(socket_push == -1) { closesocket(socket_push); return; } memset( server_addr_push, 0, sizeof(server_addr_push)); server_addr_push.sin_family = AF_INET; server_addr_push.sin_addr.s_addr =inet_addr("192.168.5.100"); server_addr_push.sin_port = htons(9895); addr_len = sizeof(struct sockaddr_in); err = bind(socket_push, (struct sockaddr *) server_addr_push, sizeof(server_addr_push)); if(err < 0) { closesocket(socket_push); return; } err = listen(socket_push, 1); if(err < 0) { closesocket(socket_push); return; } while(1) { socket_connect_push = lwip_accept(socket_push, (struct sockaddr *) connect_addr_push, addr_len); if(socket_connect_push >= 0) { send(socket_connect_push, "connect success!nr", 20, 0); break; } else { vTaskDelay(10); } } for(;;) { vTaskDelay(10); recv_push = (int)lwip_recv(socket_connect_push, (void *)data_buffer_push, 50, 0); if (recv_push > 0) { recv_time ++; if(recv_time == 32762) recv_time = 0; if(0 == strncmp((const char*)data_buffer_push, "$MTC", 4)) { CanResive_data_handle(data_buffer_push,recv_push); } } if (true == Propulsion_Flag) { Propulsion_Flag = false; Propulsion_data_handle(); send_push = send(socket_connect_push, (void *)data_propulsion_push ,strlen((char *)data_propulsion_push),0 ); if (send_push < 0) { while(1) { closesocket(socket_connect_push); socket_connect_push = lwip_accept(socket_push, (struct sockaddr *) connect_addr_push, addr_len); if(socket_connect_push >= 0) { send(socket_connect_push, "connect success!nr", 20, 0); break; } else { vTaskDelay(30); } } } }
|
|
相关推荐
1个回答
|
|
是`lwip_recv`()影响了send(),把`lwip_recv`去掉,只接收不发送的时候,接收就完全正常了
|
|
|
|
只有小组成员才能发言,加入小组>>
调试STM32H750的FMC总线读写PSRAM遇到的问题求解?
1737 浏览 1 评论
X-NUCLEO-IHM08M1板文档中输出电流为15Arms,15Arms是怎么得出来的呢?
1606 浏览 1 评论
1046 浏览 2 评论
STM32F030F4 HSI时钟温度测试过不去是怎么回事?
720 浏览 2 评论
ST25R3916能否对ISO15693的标签芯片进行分区域写密码?
1663 浏览 2 评论
1915浏览 9评论
STM32仿真器是选择ST-LINK还是选择J-LINK?各有什么优势啊?
708浏览 4评论
STM32F0_TIM2输出pwm2后OLED变暗或者系统重启是怎么回事?
557浏览 3评论
581浏览 3评论
stm32cubemx生成mdk-arm v4项目文件无法打开是什么原因导致的?
539浏览 3评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-15 16:29 , Processed in 0.981791 second(s), Total 80, Slave 63 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号