LWIP multiple connections
Posted: Thu Feb 06, 2014 3:57 pm
Hi everyone!
I desperately try to establish three TCP/IP connections (Port 12345, 7 and 80) to a STM32 Discovery board (extended by a ethernet phy, ChibiOs 2.6.2 / LWIP1.4.1).
Each connection is handled by it's own thread.
Unfortunatly, only one connection can be established at the same time.
The code for all three threads looks similar like :
I found out, that netconn_accept blocks if another connection using a different port has been established.
Any help will by appreciated.
I desperately try to establish three TCP/IP connections (Port 12345, 7 and 80) to a STM32 Discovery board (extended by a ethernet phy, ChibiOs 2.6.2 / LWIP1.4.1).
Each connection is handled by it's own thread.
Unfortunatly, only one connection can be established at the same time.
The code for all three threads looks similar like :
Code: Select all
struct netconn *conn, *newconn;
struct netbuf *rx_buffer;
uint8_t *buf;
u16_t buflen;
err_t err;
/* Create a new TCP connection handle */
conn = netconn_new(NETCONN_TCP);
LWIP_ERROR("echo_server: invalid conn", (conn != NULL), return RDY_RESET;);
/* Bind to port */
netconn_bind(conn, NULL, ECHO_THREAD_PORT);
/* Put the connection into LISTEN state */
netconn_listen(conn);
/* Goes to the final priority after initialization.*/
chThdSetPriority(ECHO_THREAD_PRIORITY);
while (1) {
/* Blocks the process until a connection request from a remote host arrives.
netconn_listen() must be called prior to netconn_accept(). */
err = netconn_accept(conn, &newconn);
if (err != ERR_OK) {
continue;
}
/* Set receive timeout */
netconn_set_recvtimeout (newconn, ECHO_RECV_TIMEOUT);
while (1) {
/* Read data from echo port */
err = netconn_recv(newconn, &rx_buffer);
...
I found out, that netconn_accept blocks if another connection using a different port has been established.
Any help will by appreciated.