Home/Support/Support Forum/Connections being RST after PSH?
New and improved user forum site coming soon
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

Connections being RST after PSH?

0 votes
Using a CC9P9215 & NET+OS I have implemented a multiple concurrent TCP socket server, using the select function.

My problem is that when one remote application is opening a port, sending data, getting a reply then closing the socket repeatedly another remote application occasionally gets an RST after a PSH. My application will accept up to 32 connections and queue up to 32 more.

I have tried limiting the second remote application to a fixed local port, and adding breakpoints in the code to trigger when a close is called for that socket/port, but it does not seem to trigger.

Has anyone had similar issues, if so what was the workaround?
asked Aug 7, 2014 in NET+OS by david.lockyer New to the Community (15 points)

Please log in or register to answer this question.

1 Answer

0 votes
Hello David

Have you looked at reducing timed-wait state. After you close a socket, it does not necessarily just return to the free pool of socket but can be held onto by the stack for (If I remember correctly) 2 minutes. Clearly this can back up and potentially leave you with no available sockets or no stack resources.

Look in the API reference guide for NAIpSetTcpMsl. It takes an unsigned int as a parameter. You'll need to try various values to tune the MSL to a value that works for your application.

NAIpSetTcpMsl is setting a GLOBAL value so you set this BEFORE you start opening sockets and it will be applied to all sockets after it is set.

Another thing to look at is as follows; Let us assume you are in a loop with a select. If the select times out or errors out add a small delay before entering the loop with the select. This gives the stack a little time to regain used resources. The size of the delay is application dependent so again you'll need to tune it for your application.
answered Aug 7, 2014 by dakotas_dad Veteran of the Digi Community (694 points)

Thanks for the info, I already had the MSL set to 0, the real problem turned out to be a bug in mapping data structures to accepted connections, resulting in the wrong connection being closed from time to time.