[MCF52235] - TCP Client - Connect/Disconnect multiple times problem

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

[MCF52235] - TCP Client - Connect/Disconnect multiple times problem

1,952 Views
Kremer
Contributor I
Hi

I´m developing a product that needs to run a tcp client.
Basically, this product will connect to TCP Servers (one at a time), and retrieve data from it by sending a command and receiving the data.
The code for the client is working with no problems for a single Server. I mean, it connects to a server, sends the command and receives the data, and does this loop with no problems at all.
But when i add more than one server, the problem starts to happen. Basically, it connects to the first server, sends the command and receives the data. Then it must disconnect from the current server and connect to the second server to do the same task. After finishing the last server, it must connect to the first server and repeats this process.
The problem is that, after disconnecting from the first server by calling m_close function, it connects to the second, then to the third and so on, but one time it fails and nothing happens anymore, basically because the memory is full. So i can see the m_connect function returns ENOMEM (error 18), wich means it could not allocate memory for the new control block.
When i make the socket non-blocking, this get worst, and sometimes it just can´t pass the second server.

Please, any advice is helpfull.
I´m based on the Interniche stack and coldfire lite project.
Labels (1)
0 Kudos
2 Replies

411 Views
Kremer
Contributor I
Oh my, after a hard debug session i could realize what i need was a fast flush of the allocated socket more then i ever needed in life!!! So after being slapped on face many times i could finally achieve the perfect desired behavior by making the socket LINGER !!! This immediately flushes all socket data, buffers and whatever it takes from RAM by calling m_close. Just thought about share this...
0 Kudos

411 Views
Umi
Contributor I

Hello,

I want to implement multi master functionality in my system by using the same tcp/ip stack from freescale , 

Can you please help me how to communicate with multiple socket?

I am unable to view your post.

0 Kudos