WIZnet Developer Forum

TCP Client not connecting

Hi, I am working on a device with the W6100 chip and having some issues with connecting to a TCP Client.
I have followed the documenation directly https://wizwiki.net/wiki/lib/exe/fetch.php/products:w6100:w6100_ds_v104e.pdf
and nothing was happening, then I found some examples for W5500 that showed that you have to run OPEN command after setting the destination address and port.
Then something start working, I got some messages in wireshark:


But it still doesn’t stay connected, on the server side I am using just plain nc and it throws an error:

Listening on 0.0.0.0 5000
nc: accept: Software caused connection abort

I am missing something after doing connect?

       struct eth_socket_mode mode = {
            .multi = 0,
            .broadcast = 0,
            .noackdelay = 0,
            .unicast = 0,
            .protocol = ETH_SOCKET_MODE_PROTOCOL_TCP4,
        };
        
        ETH_WRITE_SOCKET_CONF(priv->dev, priv->number, ETH_SOCKET_MODE, &mode, sizeof(mode));
        ETH_WRITE_SOCKET_CONF(priv->dev, priv->number, ETH_SOCKET_DEST4, &parsed_ip, sizeof(parsed_ip));
        ETH_WRITE_SOCKET_CONF(priv->dev, priv->number, ETH_SOCKET_PORT, &parsed_port, sizeof(parsed_port));
        uint8_t command = ETH_SOCKET_COMMAND_OPEN;
        ETH_WRITE_SOCKET_CONF(priv->dev, priv->number, ETH_SOCKET_COMMAND, &command, sizeof(command));

        uint64_t start = tools_get_current_ms();
        do {
            msleep(5);
            ETH_READ_SOCKET_CONF(priv->dev, priv->number, ETH_SOCKET_COMMAND, &command, sizeof(command));
            _info("command: %d\n", command);
        } while (command != 0 && tools_get_current_ms() - start < priv->timeout);

        command = ETH_SOCKET_COMMAND_CONNECT;
        ETH_WRITE_SOCKET_CONF(priv->dev, priv->number, ETH_SOCKET_COMMAND, &command, sizeof(command));

        start = tools_get_current_ms();
        do {
            msleep(5);
            ETH_READ_SOCKET_CONF(priv->dev, priv->number, ETH_SOCKET_COMMAND, &command, sizeof(command));
            _info("command: %d\n", command);
        } while (command != 0 && tools_get_current_ms() - start < priv->timeout);

Here is my code for opening TCP Connection. Any one can help me with that?

I don’t understand your environment well.
Is the w6100 a TCP server?
First of all, TCP Client’s port is 0 when viewed through wireshark.
This seems to be a problem.

I know that my code contains a lot of abstraction. Sorry about that.
W6100 is a client in this situation and is connecting to a TCP Server on my PC.
If that helps I can get some SPI capture so you can better see what is writing to W6100.

Ok I found it out! Thanks for the suggestion that the port is 0.
I tried to set 0x0114 to 14001 and now it opens.
Sadly that isn’t mention in the documentation but important that it works now :).

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