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
crypto-aes
Paul Sokolovsky 6 years ago
parent a0dbbbebb8
commit 5da8de2b66

@ -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.

@ -73,6 +73,7 @@
#define MP_ECONNABORTED (103) // Software caused connection abort
#define MP_ECONNRESET (104) // Connection reset by peer
#define MP_ENOBUFS (105) // No buffer space available
#define MP_EISCONN (106) // Transport endpoint is already connected
#define MP_ENOTCONN (107) // Transport endpoint is not connected
#define MP_ETIMEDOUT (110) // Connection timed out
#define MP_ECONNREFUSED (111) // Connection refused
@ -127,6 +128,7 @@
#define MP_ECONNABORTED ECONNABORTED
#define MP_ECONNRESET ECONNRESET
#define MP_ENOBUFS ENOBUFS
#define MP_EISCONN EISCONN
#define MP_ENOTCONN ENOTCONN
#define MP_ETIMEDOUT ETIMEDOUT
#define MP_ECONNREFUSED ECONNREFUSED

Loading…
Cancel
Save