我使用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
Solu
tionsComboMiWi 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?
0