PIC18F97J60 TCP/IP改了IP后重連問題
被這個(gè)問題困惑了幾天,之前一是需要RESET才能重新連上.今天終于搞好了.步驟如下:
1.先TCPDiscard(m_TCPServerSocket);清TCP緩沖:
2.TCPDisconnect(m_TCPServerSocket); 斷開TCP連接.
3.while(1)
{
StackTask();
if(!TCPIsConnected(m_TCPServerSocket))
break; //等待TCP斷開
}
等待TCP斷開.如果沒有斷開,則底層會(huì)出錯(cuò).
4.m_TCPServerSocket = INVALID_SOCKET; 使SOCKET無效,然后會(huì)自動(dòng)重連.
5.StackInit();初始化TCP/IP底層.
6.有UDP,需要UDPClose(MyUdpSocket);送UDP