extmod/modlwip: Fix error codes for duplicate calls to connect().

If socket is already connected, POSIX requires returning EISCONN. If
connection was requested, but not yet complete (for non-blocking
socket), error code is EALREADY.

http://pubs.opengroup.org/onlinepubs/7908799/xns/connect.html
This commit is contained in:
Paul Sokolovsky
2017-06-04 12:30:41 +03:00
parent a0dbbbebb8
commit 5da8de2b66
2 changed files with 4 additions and 2 deletions

View File

@@ -800,9 +800,9 @@ STATIC mp_obj_t lwip_socket_connect(mp_obj_t self_in, mp_obj_t addr_in) {
case MOD_NETWORK_SOCK_STREAM: {
if (socket->state != STATE_NEW) {
if (socket->state == STATE_CONNECTED) {
mp_raise_OSError(MP_EALREADY);
mp_raise_OSError(MP_EISCONN);
} else {
mp_raise_OSError(MP_EINPROGRESS);
mp_raise_OSError(MP_EALREADY);
}
}
// Register our receive callback.