void T_LwIP_TCP(void * pvArg) { struct netconn *__pstNew_TCPConn, *__pstTCPConn; struct netbuf *__pstTCPbuf; char *data; struct ip_addr addr; char *__pbData; LONG __lLen; BYTE i = 0, __bIsAdd = TRUE;
__pstTCPConn = netconn_new(NETCONN_TCP); netconn_bind(__pstTCPConn, NULL, 1001); netconn_listen(__pstTCPConn);
while(TRUE) { __pstNew_TCPConn = netconn_accept(__pstTCPConn); *AT91C_PIOA_SODR = 1; while ((__pstTCPbuf = netconn_recv(__pstNew_TCPConn)) != NULL) { *AT91C_PIOA_CODR = 1; netbuf_data(__pstTCPbuf,&__pbData,&__lLen);
netconn_write(__pstNew_TCPConn, __pbData, __lLen, NETCONN_NOCOPY); OSTimeDlyHMSM(0, 0, 1, 0); *AT91C_PIOA_SODR = 1; OSTimeDlyHMSM(0, 0, 1, 0); } *AT91C_PIOA_CODR = 1; //netbuf_delete(__pstTCPbuf); netconn_close(__pstNew_TCPConn); //while(netconn_delete(__pstNew_TCPConn) != ERR_OK) //OSTimeDlyHMSM(0, 0, 1, 0); } }
这程序是 建立一个TCP 连接,,现在出现了一个问题,就是连接建立后,收到两个包的数据后就掉去出了连接,再也连接不上了,到底问题出在那里呢???是不是我的编程有错??( 我接收到的数据包再发回PC,在PC 里显示,收到两个包之后就失去连接了,从新连接也接不起) |