完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我使用MiWi到WiFi网关DEMO EVE板,它将位于MysChIPStateCOMBOMIWI协议的项目加载到MLA的Wi-Fi网关演示板上。我试图打开服务器套接字,然后进入无限循环,以接受与以下代码的客户端连接通过这个实现,TCPPOEN函数返回一个有效的套接字,但是在进入无限循环之后,我们通过在网页中配置网络来配置网络处于基础结构模式。当网络更改为基础结构时,套接字变得无效,因此我试图用下面的代码再次打开服务器套接字,但这次TCPOPEN函数总是返回无效的套接字。因为套接字总是无效的,所以有人知道为什么TCPOpen总是返回无效的套接字吗?
以上来自于百度翻译 以下为原文 I'm using the Miwi to Wifi Gateway demo eval board which has load the project located at Microchip SolutionsComboMiWi Protocol to Wi-Fi Gateway Demo Board of the MLA. I'm trying to open a server socket before to enter in the infinite loop in order to accept client connections with the following code: LEDS_OFF(); MySocket = TCPOpen(0, TCP_OPEN_SERVER, SERVER_PORT, TCP_PURPOSE_GENERIC_TCP_SERVER); if(MySocket == INVALID_SOCKET) { LCDDisplay((char *) "INVALID_SOCKET", 0, TRUE); LED2_ON(); } gAppState = DEFAULT_STATE; while (1) { // Blink LED0 twice per sec when unconfigured, once per sec after config if ((TickGet() - t >= TICK_SECOND / (8ul - (CFGCXT.isWifiDoneConfigure * 4ul)))) { t = TickGet(); LED0_INV(); } With this implementation the function TCPOpen returns a valid socket but after enter in the infinite loop we configure the network to be in Infrastructure mode by configuring the network through the webpage. When the network changes to infrastructure the socket becomes invalid, therefore I tried to open a server socket again with the following code, but this time the TCPOpen function always return invalid socket. if (CFGCXT.isWifiDoneConfigure) { MySocket = TCPOpen(0, TCP_OPEN_SERVER, SERVER_PORT, TCP_PURPOSE_GENERIC_TCP_SERVER); if (MySocket == INVALID_SOCKET) { //LCDDisplay((char *) "INVALID_SOCKET", 0, TRUE); LED2_ON(); } else { LED2_OFF(); } } With this implementation I can connect to the server with a client but I can't send or receive data because the socket always is invalid. Somebody knows why TCPOpen always return invalid socket? |
|
相关推荐
2个回答
|
|
我通过调用TCPHOLD(MySocket)来解决问题,然后再次尝试打开套接字。
以上来自于百度翻译 以下为原文 I solved my problem by calling TCPClose(MySocket) before to try to open the socket again. |
|
|
|
|
|
|
|
只有小组成员才能发言,加入小组>>
5248 浏览 9 评论
2036 浏览 8 评论
1956 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3218 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2264 浏览 5 评论
787浏览 1评论
678浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
604浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
685浏览 0评论
582浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-27 13:53 , Processed in 1.372037 second(s), Total 78, Slave 62 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号