Skip to content

Socket connect() timeout facility needed #14102

Closed
@star297

Description

@star297

Description of defect

No control of LWIP connect() timeout.

TCPSocket needs a timeout.

@kjbracey-arm

Re issue #13056

In folder: connectivity\lwipstack\source\LWIPStack.cpp

nsapi_error_t LWIP::socket_connect(nsapi_socket_t handle, const SocketAddress &address)
{
    struct mbed_lwip_socket *s = (struct mbed_lwip_socket *)handle;
    ip_addr_t ip_addr;

    nsapi_addr_t addr = address.get_addr();
    if (!convert_mbed_addr_to_lwip(&ip_addr, &addr)) {
        return NSAPI_ERROR_PARAMETER;
    }

    //+++++++++++++++!! this is the problem !!+++++++++++++
    netconn_set_nonblocking(s->conn, false);
    //++++++++++++++++
    err_t err = netconn_connect(s->conn, &ip_addr, address.get_port());
    netconn_set_nonblocking(s->conn, true);

    return err_remap(err);
}

Could you guys remove the 'netconn_set_nonblocking(s->conn, false);' please?
To allow Socket.set_timeout(); to work.
Or something to that effect.
I believe the default is 30 seconds, I need and use timeouts in the order of 10-200ms.

I have to change this on every OS update and can't use Mbed-Online.

Target(s) affected by this defect ?

All targets that would want to use LWIP

Toolchain(s) (name and version) displaying this defect ?

Latest Mbed Studio and On-Line toolchains.

What version of Mbed-os are you using (tag or sha) ?

mbed-os-5.15.0
mbed-os-6.6.0

What version(s) of tools are you using. List all that apply (E.g. mbed-cli)

Mbed Studio
Mbed Studio-Online
Mbed OnLine

How is this defect reproduced ?

Calling a connect() timeout of 100ms

my_socket.set_timeout(100);

has no effect on the default connect() timeout that appears to be around 30 seconds.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions