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.

cc3100 tcp断开后的状态位

Other Parts Discussed in Thread: CC3100

请问TI工程师,我在用cc3100实现TCP协议,我的CC3100作server端,PC作client端。我的client端从连接状态断开后,CC3100有没有一个状态位指示已经断开了?如果有的话,这个状态位是什么?谢谢!

  • 连接断开是和AP断开连接?在回调函数中void SimpleLinkWlanEventHandler(SlWlanEvent_t *pWlanEvent) 中会有断开网络的提示信息

    case SL_WLAN_DISCONNECT_EVENT:
    {
    slWlanConnectAsyncResponse_t* pEventData = NULL;

    CLR_STATUS_BIT(g_ulStatus, STATUS_BIT_CONNECTION);
    CLR_STATUS_BIT(g_ulStatus, STATUS_BIT_IP_AQUIRED);

    pEventData = &pWlanEvent->EventData.STAandP2PModeDisconnected;

    // If the user has initiated 'Disconnect' request,
    //'reason_code' is SL_USER_INITIATED_DISCONNECTION
    if(SL_USER_INITIATED_DISCONNECTION == pEventData->reason_code)
    {
    UART_PRINT("[WLAN EVENT]Device disconnected from the AP: %s,"
    "BSSID: %x:%x:%x:%x:%x:%x on application's request \n\r",
    g_ucConnectionSSID,g_ucConnectionBSSID[0],
    g_ucConnectionBSSID[1],g_ucConnectionBSSID[2],
    g_ucConnectionBSSID[3],g_ucConnectionBSSID[4],
    g_ucConnectionBSSID[5]);
    }
    else
    {
    UART_PRINT("[WLAN ERROR]Device disconnected from the AP AP: %s,"
    "BSSID: %x:%x:%x:%x:%x:%x on an ERROR..!! \n\r",
    g_ucConnectionSSID,g_ucConnectionBSSID[0],
    g_ucConnectionBSSID[1],g_ucConnectionBSSID[2],
    g_ucConnectionBSSID[3],g_ucConnectionBSSID[4],
    g_ucConnectionBSSID[5]);
    }
    memset(g_ucConnectionSSID,0,sizeof(g_ucConnectionSSID));
    memset(g_ucConnectionBSSID,0,sizeof(g_ucConnectionBSSID));
    }
    break;

  • 目前CC3100还不会将TCP FIN上传到应用层。所以需要应用层自己去探测。可以用发送数据的方式来探测。

  • 嗯,我后面就是在发送数据或者接受数据失败的时候重新新建Socket等待连接,实现了断开后能够再次连接的功能,就是不知道这样设计合不合理。

  • 这样可以的,需要服务器和客户端配合好。套接字在关的时候,应该会发一个TCP FIN出来的,客户端那边再重连一次就好了。