Hello! I have implemented a simple TCP server on lwIP 1.4.1 running on chibiOS (a realtime OS) with the netconn api on an STM32F746.
It goes like this: TCP server is opened and waits for connections: conn = netconn_new(NETCONN_TCP); LWIP_ERROR("http_server: invalid conn", (conn != NULL), chThdExit(MSG_RESET);); netconn_bind(conn, NULL, SERVER_THREAD_PORT); netconn_listen(conn); err_t err; while (true) { err = netconn_accept(conn, &newconn); if (err != ERR_OK) continue; serve(newconn); netconn_delete(newconn); } The serve function kicks in when a connection was accepted and receives some data from the client: void serve(struct netconn * conn) { struct netbuf *inbuf; uint8_t *buf; u16_t buflen; err_t err; /* * Read the data from the port, blocking if nothing yet there. * Assume that the request is in one netbuf. */ err = netconn_recv(conn, &inbuf); if (err == ERR_OK) { netbuf_data(inbuf, (void **)&buf, &buflen); // evaluate the input! } /* Close the connection */ netconn_close(conn); /* * Delete the buffer (netconn_recv gives us ownership, * so we have to make sure to deallocate the buffer) */ netbuf_delete(inbuf); } My TCP client (it is a Matlab PC) connects, sends some data, and disconnects. The TCP server also closes the connection on its side and then deletes the netconn structure. The problem is that I get spurious ACK and FIN, ACK in Wireshark. I do not get those, when I do not let Matlab close the TCP connection on client side. However, I have to, since I want to open it again. The spurious retransmission does not hurt my system but I wonder why it exists. Is there something that is obviously wrong? Should I NOT close the connection on the TCP server side? Find a capture attached. Thanks in advance, Adrian
dump.pcapng
Description: dump.pcapng
_______________________________________________ lwip-users mailing list lwip-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/lwip-users