We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello all,
I'm using the MDK-ARM 3.11 and RTL-ARM 3.10 in combination with a MCB2300 Demo board. As a part of my application I want to transfer some files from the embedded board to a computer. Therefore I have written embedded client that sends a file blockwise through tcp to the computer.
The client is working but I have a problem with the error handling. To save the extra memory for a buffer and to avoid unnecessary memory copying I allocate a buffer with the correct blocksize from the TCPnet buffer and directly read the next fileblock into this buffer. It's working great.
But I have a problem in the case of an error on reading from the file. In this situation I dont send the already allocated buffer, because the data is invalid. As a result I'm unable to release this memory again. I tried to close and release the socket but this doesn't seem release the already allocated memory. After some errors I always get a "out of memory" error from the TCPnet.
1.Does the tcp_release_socket function automatically release TCPnet memory that was already allocated but not send yet?
2.How can I release memory from TCPnet, that I allocated before, without sending it?
Thanks in advance for your replies.
Rainer
1. no, tcp_release_socket() does not automatically release dynamic memory allocated for TCP socket.
2. to release a memory, call tcp_send(socket, buf, 0).
When dlen is 0, the packet is not transmitted, the memory is released and function returns. This call will of course print an error message on debug serial port if you are using a debug version of TCPnet library.
Franc
You are right, it's working now.
Thank you very much!