Mbed-os: Socket::open() behaviour with no network connectivity

Created on 11 Aug 2016  路  8Comments  路  Source: ARMmbed/mbed-os

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?

closed_in_jira mirrored tracking bug

All 8 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cesarvandevelde picture cesarvandevelde  路  4Comments

pilotak picture pilotak  路  3Comments

davidantaki picture davidantaki  路  3Comments

sarahmarshy picture sarahmarshy  路  4Comments

ghost picture ghost  路  4Comments