Hi Everyone
I just finished porting my project from MQX 4.0 to MQX 4.1. We are using a custom platform that is very close to TWRK60M512 tower board with some minor pinout differences.
I have a TCP client application (Modbus protocol client) which is working perfectly on the MQX4.0.
The client app is quite simple:
1. Connect to 6 servers using 6 sockets
2. Read the data (modbus tcp data) from those sockets
When i tired to run the same app after porting it (replacing the old MQX datatypes with the C99 style ones) and running it i get a really strange behaviour.
I attach a wireshark PCAP file which can explain it way better then with words. Basically after i Open 6 sockets and start reading the data, RTCS sends TCP RESET to the server.
So i made a test. I have called connect() 6 times with 6 different sockets and paused the debugger right after that. All 6 sockets are opened, see attached picture.
After that, i have performed one Modbus TCP request to only the 1st socket. But the other 4 sockets were issued a TCP RESET command from RTCS and it is visible on the captured as well.
Can anyone shed any light on what might be going on there? I know for sure there are no stack smashed (i increased the stacks and it checked with TAD plugin, all at around 40%-65%).
Any help would be greatly appreciated.
Also, here are the socket options that i set to all of those 6 sockets:
VOID MBPTCPSetSockOptions(SOCKET iSocket)
{
UINT option = 0;
option = 5000;
ULONG retval = RTCS_OK;
retval |= setsockopt(iSocket, SOL_TCP, OPT_CONNECT_TIMEOUT, &option, sizeof(option));
option = 400; //380
retval |= setsockopt(iSocket, SOL_TCP, OPT_RBSIZE, &option, sizeof(option));
option = 400; //380
retval |= setsockopt(iSocket, SOL_TCP, OPT_TBSIZE, &option, sizeof(option));
option = 1;
retval |= setsockopt(iSocket, SOL_TCP, OPT_NO_NAGLE_ALGORITHM, &option, sizeof(option));
option = 0;
retval |= setsockopt(iSocket, SOL_TCP, OPT_RECEIVE_NOWAIT, &option, sizeof(option));
option = 1;
retval |= setsockopt(iSocket, SOL_TCP, OPT_RECEIVE_PUSH, &option, sizeof(option));
option = 0;
retval |= setsockopt(iSocket, SOL_TCP, OPT_SEND_NOWAIT, &option, sizeof(option));
option = 1;
retval |= setsockopt(iSocket, SOL_TCP, OPT_SEND_PUSH, &option, sizeof(option));
option = 0;
//retval |= setsockopt(iSocket, SOL_TCP, OPT_TIMEWAIT_TIMEOUT, &option, sizeof(option));
option = 100;
retval |= setsockopt(iSocket, SOL_TCP, OPT_RECEIVE_TIMEOUT, &option, sizeof(option));
option = 30; //30 seconds keep alive
retval |= setsockopt(iSocket, SOL_TCP, OPT_KEEPALIVE, &option, sizeof(option));
if(RTCS_OK != retval)
{
TASK_BLOCK();
}
}
Thanks in advance