fnHandleTCP()

void fnHandleTCP(unsigned char *tcp_data, IP_PACKET *received_ip_packet, unsigned short usLen);

tcp_data is a pointer to the TCP content of a reception frame.

received_ip_packet is a pointer to the IP content of a reception frame.

usLen is the length of the TCP content of the reception frame.


This routine is generally used only be the Ethernet task. The Ethernet task receives all frames, recognises those with TCP content and passes them to the TCP layer using this call.

Generally the TCP/IP frame passed to the routine is still in the Ethernet reception buffer. The buffer is locked and so will not be overwritten by further Ethernet reception during its handling.

TCP frames are only handled when the project define USE_TCP is active. For TCP to be used, also the project define USE_IP must be active.

Example

This example shows how the Ethernet task handles frames based on IP and then passes TCP types to be treated. Any unrecognised types will be silently ignored. Once the TCP handling has completed the Ethernet buffer holding its data is freed so that it can be reused by the Ethernet controller.

    ....
    if ((usIPLength = fnHandleIP(&rx_frame, &usTotalLength)) != 0) { // if IP handle it
        switch (rx_frame.ptEth->ucData[IP_PROTOCOL_OFFSET]) { // valid IP frame
        ....
        case IP_TCP:
            fnHandleTCP(&rx_frame.ptEth->ucData[usIPLength], (IP_PACKET *)&rx_frame.ptEth->ucData, (unsigned short)(usTotalLength - usIPLength));
            break;
        ....
        default:
            break;
        }
    }
    fnFreeBuffer(Ethernet_handle, cEthernetBuffer);          // free up the receiver buffer since we have completed
    ....


See the following forum thread for additional details about working with TCP sockets: µTasker forum TCP discussion.

Related functions

fnGetTCP_Socket();
fnReleaseTCP_Socket();
fnReportTCPWindow(); fnGetTCP_state();
fnTCP_Activity();
fnTCP_Connect();
fnTCP_close();




Please use the µTasker forum to ask specific questions.