Thank you for sending the Wireshark recording. According to our analysis, the issue was caused by slow [ACK] sent by the server which occurred onlly after the client has sent the second data packet. As a result the second packet overwrote the regen buffer and was sent as a duplicate packet (using the same Seq and Ack # as the first packet) The server therefore ignored the second data packet because it has already successfully received the first data packet and simply drop any duplicate transmission it received. The slow [ACK] sent by the server was therefore the trigger of the out-of-sequence packets.
We recommend the following possible solutions:
1) Program the server to send a data response such as "OK"+CRLF back to the client after the client have sent the data. This allows a handshake between the client and the server at the application layer since the TBASIC software can determine that the first packet has been received before sending the second data packet. This has other advantages, which is for the client to resend the first data packet in case it is actually lost in the cyberspace. In some situations, a continuous communication loss could signal something seriously wrong and the PLC could be programmed to reboot a network switch, a router or a modem or even to reboot itself in order to restore communication especially in a remote, unattended installation.
Or,
2) Concatenate the second data string with the first data string and sent out as a single packet. This would save some bandwidth too. You can embed the CRLF as terminator between the two data packets such as:
PRINT #4 A$; "\0D\0A"; B$
Where A$ and B$ are the data strings for the first set and second set of data respectively. "\0D\0A" would append the CR+LF to the A$ and followed by B$ and will end with a second set of CR+LF.
However, the above two strings would be sent out in a single data packet which your server can then easily separate them into two data packets.
3) Schedule the second data string to be sent later than the longest [ACK] delay it could experience. A delay of 10 to 20 seconds will ensure that the first data packet is either completely sent or aborted by the client and it can then send the second data packet.