本帖最后由 captainliuy 于 2016-9-9 14:58 编辑 启动任务调用如下函数建立了一个server线程void tcp_server_init(void) { sys_thread_new("tcp_server", tcp_server_thread, NULL, DEFAULT_THREAD_STACKSIZE, TCPECHO_THREAD_PRIO); } 线程函数如下:static void tcp_server_thread(void *arg) { int sock, newconn, size; struct sockaddr_in address, remotehost; LWIP_UNUSED_ARG(arg); /* create a TCP socket */ if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) { return; } /* bind to port 80 at any interface */ address.sin_family = AF_INET; address.sin_port = htons(80); address.sin_addr.s_addr = INADDR_ANY; if (bind(sock, (struct sockaddr *)&address, sizeof (address)) < 0) { return; } /* listen for incoming connections (TCP listen backlog = 5) */ listen(sock, 5); size = sizeof(remotehost); while (1) { newconn = accept(sock, (struct sockaddr *)&remotehost, (socklen_t *)&size); http_server_serve(newconn); } } 在调用socket和bind函数的过程失败后都有return,任务return不是会出问题吗? |
你可以再lwip重故意返回一个错误值试试。经验就是这么积累起来的,不是问出来的。