Hi
The only thing to be careful with is trying to add more data to the TCP buffer than it can accept; once data is in the buffer it will be transmitted automatically (together with your listener).
To achieve maximum throughput for a particular TCP buffer size (where larger size means faster throughput in exchange for greater memory requirements) the following technique is used:
1) Ensure that WAKE_BLOCKED_TCP_BUF is enabled (should be by default)
2) When sending data, fill the buffer as much as possible.
static const UTASK_TASK OurTask = OWN_TASK;
while ((!fnSendBufTCP(Telnet_socket, (unsigned char *)&OurTask, nr_of_bytes, TCP_BUF_CHECK)) != 0) {
fnSendBufTCP(Test_socket, (unsigned char *)test_message, nr_of_bytes, (TCP_BUF_SEND | TCP_BUF_SEND_REPORT_COPY))
}
This will fill the TCP buffer with as many messages as possible; by adjusting the TCP buffer size to match message length (eg. so that exactly 2 or 3 fit) can also improve efficiency when fixed message lengths are used.
3) When the TCP buffer has space, your task will receive a TX_FREE event. Handle this to immediately add further data - eg.
while ( fnRead( PortIDInternal, ucInputMessage, HEADER_LENGTH )) { // check input queue
switch ( ucInputMessage[ MSG_SOURCE_TASK ] ) { // switch depending on message source
case INTERRUPT_EVENT:
if (TX_FREE == ucInputMessage[MSG_INTERRUPT_EVENT]) {
// call the transmission loop again here
}
break;
The result is that the TCP buffer is always filled as soon as it needs more data but never overfilled. This will keep bulk TCP operation flowing and so achieve high bulk data throughput.
Regards
Mark