FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [September 2016 Threads] TCP - Cane a Socket be used for multiple connects and shutdownsPosted by joehinkle on September 28, 2016 I'm thinking about heap fragmentation.
I'm using heap4.
I have to acquire from 1 to 5 files from a Server.
Currently, I'm shutting down each connection after a file is acquired (think HTTP 1.0). and closing the socket.
Since a TCP socket acquires multiple buffers from the heap, each time a file is processed, buffers are acquired and freed from the heap because the socket is being acquired and freed.
Can a task acquire a socket and then perform multiple connects and shutdowns on the socket without closing the socket?
Thanks.
Joe
TCP - Cane a Socket be used for multiple connects and shutdownsPosted by rtel on September 28, 2016 Hi Joe,
I think this should be legal, according to the TCP state machine, but it will mean you will create a new connection using the same IP address and port number, and I believe that has the potential to cause problems with anything in between your client and server (firewalls, routers, etc.) that could could maintain state of the previous connection. I will have to defer to Hein for anything further.
Regards.
TCP - Cane a Socket be used for multiple connects and shutdownsPosted by joehinkle on September 28, 2016 I am/was concerned about internal socket data not getting re-initialized with each connection. You inferred that, I think, by stating that the port number might not be changed with a new connection.
Local Port number being associated wth socket and not the current connection. Is this a socket specification or an implementataion action?
Thanks.
Joe
TCP - Cane a Socket be used for multiple connects and shutdownsPosted by heinbali01 on September 28, 2016
Can a task acquire a socket and then perform multiple connects
and shutdowns on the socket without closing the socket?
Unfortunately that is not possible.
The only socket that can connect multiple times is a server socket that uses the resocket option FREERTOS_SO_REUSE_LISTEN_SOCKET . That is no use for you now.
Have you really seen that a lot of fragmentation occurs? Because normally, when you allocated N blocks, and then de-allocate them (in any order), there should be no fragmentation left.
heap4 will split-up memory blocks, but free will join the blocks again.
TCP - Cane a Socket be used for multiple connects and shutdownsPosted by rtel on September 28, 2016 The port number is assigned when the socket is 'bound'. Re-using the
socket does not re-bind the socket. It may be possible to explicitly
re-bind the socket by calling FreeRTOS_bind(), but I would have to check
the source code to see if that would work - it is possible the bind()
function will only proceed if the socket is not already bound to a port.
TCP - Cane a Socket be used for multiple connects and shutdownsPosted by joehinkle on September 28, 2016 Fragmentation was just a concern -- I have not investigated actual results, just potential concern because of my process.
TCP - Cane a Socket be used for multiple connects and shutdownsPosted by heinbali01 on September 28, 2016
Currently, I'm shutting down each connection after a file is
acquired (think HTTP 1.0). and closing the socket.
Is it really important to stay HTTP 1.0 compatible?
In all my HTTP client applications, a socket will do multiple GET's without closing the connection in-between and I can not remember that it ever cause a problem.
TCP - Cane a Socket be used for multiple connects and shutdownsPosted by joehinkle on September 28, 2016 I'm modifing my process flow to keep the connection open to see how THAT works.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|