WIZnet Developer Forum

recv Function in socket.c

While looking through the recv function I see what looks like a bug that I haven’t been able to track down online. Here’s the code in question.

        while (1)
        {
            recvsize = getSn_RX_RSR(sn);
            tmp = getSn_SR(sn);

            if (tmp != SOCK_ESTABLISHED)
            {
                if (tmp == SOCK_CLOSE_WAIT)
                {
                    if (recvsize != 0) 
                    {
                        break;
                    }
                    else if (getSn_TX_FSR(sn) == getSn_TxMAX(sn))
                    {
                        close(sn);
                        return SOCKERR_SOCKSTATUS;
                    }
                }
                else
                {
                    close(sn);
                    return SOCKERR_SOCKSTATUS;
                }
            }

            if ((sock_io_mode & (1 << sn)) && (recvsize == 0)) return SOCK_BUSY;

            if (recvsize != 0) break;
        };

The line: else if (getSn_TX_FSR(sn) == getSn_TxMAX(sn))
is bothering me. Why are we looking at the TX registers rather than the RX registers? I can’t get this to make sense.

Comments welcome!
Just David

When I send an email to WIZnet, they tell me to post my issues here. Well, I’ve done that… Could I get a WIZnet response, please? Pretty please!

hi David,

Chip and MCU communicate. This is the process of double-checking the data sent.

else if (getSn_TX_FSR(sn) == getSn_TxMAX(sn)) is It reads the register value on the chip.

Thank you.

But, why is it checking the TX registers rather than the RX registers? This the recv() function.

Copyright © 2017 WIZnet Co., Ltd. All Rights Reserved.