Chat freely about anything...

User avatar
By dkinzer
#20308 I have been working on code for a UDP server. It is a simple server that sends a datagram back to the remote host whenever it receives a datagram on a specific port. The app seems to work correctly over many iterations (as tested with the SendPacket application) as long as I comment out the deallocation of a data structure that I use to track connections (of course this results in a memory leak). With the deallocation present, which occurs after the reply is sent back to the remote host, the app doesn't respond to any further datagrams.

I've been testing this using the v1.1.0 SDK.

I've stripped the app down to the essential code to demonstrate the issue. Someone with access to the core code should be able to determine what is happening that causes the apparent heap corruption. The demo code can be found at the URL below. The readme.txt file in the .zip file has further details on the line of code that affects the behavior.

http://www.kinzers.com/bluebird/esp8266_UDP_server.zip
User avatar
By dkinzer
#20399 Well, I'm happy to say that I was barking up the wrong tree. The deallocation call wasn't causing the problem as I had thought. Rather, the problem was that when receiving multiple messages from the same host the struct espconn pointer passed to the received callback can point to the same block of memory. My original code relied on the assumption that the struct espconn block would be created anew for each message. The new code, found in the attached .zip file, no longer uses the 'reverse' pointer of the passed struct espconn to locate the connection related to the listening. Now, the connection table is scanned to find an entry corresponding to the listener.
Attachments
(10.48 KiB) Downloaded 213 times