Hi all,
I am trying to run the tcpecho sample code from
http://cvs.savannah.gnu.org/viewvc/contrib/apps/tcpecho/?root=lwip in a
multithreaded application running on an TSK3000 soft processor embedded in an
FPGA. In another thread, some example HTTP server code has been working very
well, and continues to work despite the broken TCP socket thread.
I'm using a TCP packet sender and monitoring via Wireshark to send a simple
ASCII data. Wireshark sees the TCP packet being sent to the correct destination
IP / port, but I get no response from the echo.
The following section of code (I believe) shows netconn_accept( ) never
returns, as I never get the printed "accepted new connection" dialog (while I
do get the "Grabbing new connection..." dialog printed.
DIAG("Grabbing new connection...\n");
err = netconn_accept(conn, &newconn);
DIAG("accepted new connection %p\n", newconn);
Any ideas on how to further debug this - if you can't tell, I'm very new to
LWIP and embedded network programming in general - would be much appreciated.
Thanks,
Eric
#include <string.h>
#include <ctype.h>
#include <pthread.h>
#include "devices.h"
#include "DIAG.h"
#include <per_ioport.h>
#include <lwip.h>
#include <lwip/netif.h>
#include <lwip/tcpip.h>
#include <lwip/sockets.h>
#include "lwip/api.h"
extern pthread_mutex_t printf_mutex;
void tcpecho_thread(void)
{
struct netconn *conn, *newconn;
err_t err;
//LWIP_UNUSED_ARG(arg);
/* Create a new connection identifier. */
conn = netconn_new(NETCONN_TCP);
/* Bind connection to well known port number 7. */
netconn_bind(conn, NULL, 8989);
/* Tell connection to go into listening mode. */
netconn_listen(conn);
DIAG("Listning on 8989\n");
while (1) {
/* Grab new connection. */
DIAG("Grabbing new connection...\n");
err = netconn_accept(conn, &newconn);
DIAG("accepted new connection %p\n", newconn);
/* Process the new connection. */
if (err == ERR_OK) {
struct netbuf *buf;
void *data;
u16_t len;
while ((err = netconn_recv(newconn, &buf)) == ERR_OK) {
DIAG("Recved\n");
do {
netbuf_data(buf, &data, &len);
err = netconn_write(newconn, data, len, NETCONN_COPY);
#if 0
if (err != ERR_OK) {
DIAG("tcpecho: netconn_write: error \"%s\"\n", lwip_strerr(err));
}
#endif
} while (netbuf_next(buf) >= 0);
netbuf_delete(buf);
}
DIAG("Got EOF, looping\n");
/* Close connection and discard connection identifier. */
netconn_close(newconn);
netconn_delete(newconn);
}
else
{
DIAG(lwip_strerr(err));
}
}
}
_______________________________________________
lwip-users mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/lwip-users