How to disconnect and reconnect again?

The disconnect() will do the FIN/ACK dance so that both sides can close sockets gracefully, assuming the connection has been maintained. Otherwise, the disconnect() will perform close() on timeout. Here is the source code from the ioLibrary -

/**
 * @ingroup WIZnet_socket_APIs
 * @brief Try to disconnect a connection socket.
 * @details It sends request message to disconnect the TCP socket 'sn' passed as parameter to the server or client.
 * @note It is valid only in TCP server or client mode. \n
 *       In block io mode, it does not return until disconnection is completed. \n
 *       In Non-block io mode, it return @ref SOCK_BUSY immediately. \n

 * @param sn Socket number. It should be <b>0 ~ @ref \_WIZCHIP_SOCK_NUM_</b>.
 * @return @b Success :   @ref SOCK_OK \n
 *         @b Fail    :\n @ref SOCKERR_SOCKNUM  - Invalid socket number \n
 *                        @ref SOCKERR_SOCKMODE - Invalid operation in the socket \n
 *                        @ref SOCKERR_TIMEOUT  - Timeout occurred \n
 *                        @ref SOCK_BUSY        - Socket is busy.
 */

int8_t disconnect(uint8_t sn)
{
    CHECK_SOCKNUM();
    CHECK_SOCKMODE(Sn_MR_TCP);
    setSn_CR(sn, Sn_CR_DISCON);
    /* wait to process the command... */
    while (getSn_CR(sn));
    sock_is_sending &= ~(1 << sn);
    if (sock_io_mode & (1 << sn)) return SOCK_BUSY;
    while (getSn_SR(sn) != SOCK_CLOSED)
    {
        if (getSn_IR(sn) & Sn_IR_TIMEOUT)
        {
            close(sn);
            return SOCKERR_TIMEOUT;
        }
    }
    return SOCK_OK;
}