You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current TcpStack trait doesn't facilitate well for a connect() operation that cannot be completed in a blocking manner. For example, a socket may have called connect(), but is_connected() may return false because the TCP handshake has not completed.
As such, it's required that an application repeatedly call connect() on a socket whenever is_connected() returns false to ensure that an active connection is being made. A single call to connect() may fail due to TCP state mismatch and other related problems within the network stack (see smoltcp-rs/smoltcp#367).
If the network stack isn't implemented to support repeatedly calling connect() on a socket that may already be connecting (but not yet connected), this can have unexpected consequences.
Is it possible for us to extend the TcpStack trait to either:
include an is_connecting() API
Modify the is_connected() API to return an enum indicating the state of the TCP connection (e.g. connecting, disconnected, or connected)
Have connect() return a non-exhaustive error enumeration that allows us to specify if a socket is already in the connecting process
I'm curious to hear some other thoughts on this as well. I'm looking to use these traits for an embedded MQTT client library that's targeting multiple network stacks (e.g. an external "hardware" network stack on a W5500 and a smoltcp network stack for a different device).
I've tried to describe the problem I'm having in an issue for minimq, which relies on a TCP network stack, so there's further context attached there.
The text was updated successfully, but these errors were encountered:
ryan-summers
changed the title
Support for asyncrhonous TCP connections
Support for asynchronous TCP connections
Aug 26, 2020
Perhaps the best approach to dealing with this is instead to return an error if the connect() method fails and then allow connect() to be a blocking operation. See #18
Uh oh!
There was an error while loading. Please reload this page.
The current
TcpStack
trait doesn't facilitate well for aconnect()
operation that cannot be completed in a blocking manner. For example, a socket may have calledconnect()
, butis_connected()
may return false because the TCP handshake has not completed.As such, it's required that an application repeatedly call
connect()
on a socket wheneveris_connected()
returns false to ensure that an active connection is being made. A single call toconnect()
may fail due to TCP state mismatch and other related problems within the network stack (see smoltcp-rs/smoltcp#367).If the network stack isn't implemented to support repeatedly calling
connect()
on a socket that may already be connecting (but not yet connected), this can have unexpected consequences.Is it possible for us to extend the
TcpStack
trait to either:is_connecting()
APIis_connected()
API to return an enum indicating the state of the TCP connection (e.g. connecting, disconnected, or connected)connect()
return a non-exhaustive error enumeration that allows us to specify if a socket is already in the connecting processI'm curious to hear some other thoughts on this as well. I'm looking to use these traits for an embedded MQTT client library that's targeting multiple network stacks (e.g. an external "hardware" network stack on a W5500 and a
smoltcp
network stack for a different device).I've tried to describe the problem I'm having in an issue for minimq, which relies on a TCP network stack, so there's further context attached there.
The text was updated successfully, but these errors were encountered: