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