|

楼主 |
发表于 2018-8-7 19:06:03
|
显示全部楼层
测试任务如下
void TCPnetTest(void)
{
int32_t iCount;
uint8_t *sendbuf;
uint8_t tcp_status;
uint16_t maxlen;
uint8_t res;
OS_ERR err;
CPU_TS ts;
OS_FLAGS xResult;
/*
创建TCP Socket并创建监听,客户端连接服务器后,10秒内无数据通信将断开连接。
但是由于这里使能了TCP_TYPE_KEEP_ALIVE,会一直保持连接,不受10秒的时间限制。
*/
// socket_tcp = tcp_get_socket (TCP_TYPE_SERVER|TCP_TYPE_KEEP_ALIVE, 0, 10, tcp_callback);
socket_tcp = tcp_get_socket (TCP_TYPE_SERVER, 0, 10, tcp_callback);
if(socket_tcp != 0)
{
res = tcp_listen (socket_tcp, PORT_NUM);
printf_debug("tcp listen res = %d\r\n", res);
}
while (1)
{
/* RL-TCPnet处理函数 */
main_TcpNet();
/* 用于网线插拔的处理 */
tcp_status = TCP_StatusCheck();
}
}
串口打印信息如下
tcp listen res = 1
IP:远程客户端
肭罅?覫P: 192.168.1.20 port:55129
Socket is connected
to remote peer
还是没有等待期待的“Connection has
been closed”
代码没问吧,我用的是LAN8720,目前没有加轮训断线检测,跟这个没关系吧
|
|