Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

TCP - Cane a Socket be used for multiple connects and shutdowns

Posted 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 shutdowns

Posted 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 shutdowns

Posted 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 shutdowns

Posted 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 shutdowns

Posted 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 shutdowns

Posted 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 shutdowns

Posted 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 shutdowns

Posted by joehinkle on September 28, 2016

I'm modifing my process flow to keep the connection open to see how THAT works.


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists