Calling Socket::open() before EthernetInterface::connect() results in sys_arch_protect error.
As a NetworkInterface instance is required by sockets (as documented), I wouldn't necessarily expect it to work (although possibly not with that specific error).
But, as long as EthernetInterface::connect() has been called once, even if DHCP fails or connect() is immediately followed by EthernetInterface::disconnect(), I can then open sockets as if I had working network connectivity.
Is this the intended behaviour in each situation?
cc @geky
Thanks for reporting this. You are right, this error should be reported more consistently (perhaps with NSAPI_ERROR_PARAMETER). Opening sockets on a disconnect interface should fail as well.
There is also the situation in which a socket is left open through a network disconnect call. I propose we leave this as undefined behaviour due to the complexity in enforcing a consistent error (the EthernetInterface may have been freed at that point).
Sounds good to me.
ARM Internal Ref: IOTMORF-444
This should be fixed on https://github.com/ARMmbed/mbed-os/pull/2561, let me know if there's still and issue
@tommikas Is this resolved?
Yep. Just been waiting for the changes to land on master. Closing now.