Raw TCP Client and Server NO_SYS

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Raw TCP Client and Server NO_SYS

Pedro
Hello there, how are you?

Well, I'm working with a STM32H7 board and lwIP stack (2.0.3), no RTOS. The idea is running a TCP Client and a TCP Server at the same time, so I've started using echo demos as reference. TCP Client can use an IP address or a host name, so "dns_gethostbyname" is helping me. Also, I've set TCP_SYNMAXRTX to 3, so if no Server is found, "tcp_err" is called to close the client and then, try again later ("tcp_new").

To test the routine, I've provided a simple terminal on my Windows, with both TCP Client and Server functions. So if I type the board IP address and Port, I can connect to lwIP Server. And if I opens a Port, lwIP Client connects to it.

Everything works fine if lwIP Client connects first. If lwIP Server gets a connection first or even if Windows server is offline, the board get stucked on "tcp_fasttmr" method, with "pcb" and "pcb->next" pointing to the same address (established Server).

I've created some kind of state machine for both connection, running on main while, so I can't see any concurrent process (maybe SYNC by lwIP and the Server stack?).

Do you have any clue how can I solve this? I'm planning to add more functions to my board, something close to Microchip TCPIP stack, with HTTP server, DDNS and NTP clients.

Thanks a lot!

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: Raw TCP Client and Server NO_SYS

Yasir Arafat
In a very similar problem I endup corrupting tcp_active_pcbs in circular linked list. After hard debugging I found that mem_free() called twice for a single connection to free a closing connection. 

On Mon, 3 Jun, 2019, 3:55 AM Pedro, <[hidden email]> wrote:
Hello there, how are you?

Well, I'm working with a STM32H7 board and lwIP stack (2.0.3), no RTOS. The idea is running a TCP Client and a TCP Server at the same time, so I've started using echo demos as reference. TCP Client can use an IP address or a host name, so "dns_gethostbyname" is helping me. Also, I've set TCP_SYNMAXRTX to 3, so if no Server is found, "tcp_err" is called to close the client and then, try again later ("tcp_new").

To test the routine, I've provided a simple terminal on my Windows, with both TCP Client and Server functions. So if I type the board IP address and Port, I can connect to lwIP Server. And if I opens a Port, lwIP Client connects to it.

Everything works fine if lwIP Client connects first. If lwIP Server gets a connection first or even if Windows server is offline, the board get stucked on "tcp_fasttmr" method, with "pcb" and "pcb->next" pointing to the same address (established Server).

I've created some kind of state machine for both connection, running on main while, so I can't see any concurrent process (maybe SYNC by lwIP and the Server stack?).

Do you have any clue how can I solve this? I'm planning to add more functions to my board, something close to Microchip TCPIP stack, with HTTP server, DDNS and NTP clients.

Thanks a lot!
_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: Raw TCP Client and Server NO_SYS

Fatih Özay
Hello Yasir,

I am struggling with exactly same problem. Which mem_free's called twice ?
Could you describe more and share the fix ?

Thanks in advance

Fatih



--
Sent from: http://lwip.100.n7.nabble.com/lwip-users-f3.html

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users