You are reading a single comment by @Kolban and its replies.
Click here to read the full conversation.
-
I find that a socket creation request is sent to the board driver and then IMMEDIATELY, the connected callback is invoked.
I don't see how this couldn't be a bug, unless the call is expected to block until the part returns a confirmation that it's finished - which would sort of defeat the point of passing a callback...
In the architecture of the "net.connect()" function we can supply a callback function that will be invoked when a connection has been established. The parameter to the callback function is the Socket data structure that represents the connection. This is all sound.
However, studying the socketserver.c source (lines 700-712), I find that a socket creation request is sent to the board driver and then IMMEDIATELY, the connected callback is invoked. This is a problem for some board implementations (such as the ESP8266) which have their own callbacks to indicate when the connection has been established.
What this means is that today ... if I call "net.connect()", the connected callback is invoked before we have actually established a real connection through the board interface. What it seems we need is some form of integration with the board's concept of when a connection is ready.