@@ -50,22 +50,6 @@ static int socketpool_type_to_airlift_type(socketpool_socketpool_sock_t type) {
5050 }
5151}
5252
53- // // The SOCKETPOOL_ constants are actually the same as the LWIP constants, but it's
54- // // possible they might not be, so map them, just in case.
55- // static socketpool_socketpool_sock_t airlift_type_to_socketpool_type(int type) {
56- // switch (type) {
57- // case SOCK_STREAM:
58- // return SOCKETPOOL_SOCK_STREAM;
59- // case SOCK_DGRAM:
60- // return SOCKETPOOL_SOCK_DGRAM;
61- // case SOCK_RAW:
62- // return SOCKETPOOL_SOCK_RAW;
63- // default:
64- // mp_raise_ValueError_varg(MP_ERROR_TEXT("Invalid %q"), MP_QSTR_type);
65- // }
66- // }
67-
68-
6953static bool _socketpool_socket (socketpool_socketpool_obj_t * self ,
7054 socketpool_socketpool_addressfamily_t family , socketpool_socketpool_sock_t type ,
7155 int proto ,
@@ -279,8 +263,7 @@ int common_hal_socketpool_socket_bind(socketpool_socket_obj_t *self,
279263 mp_raise_RuntimeError_varg (MP_ERROR_TEXT ("%q in use" ), MP_QSTR_socket );
280264 }
281265 if (self -> bound ) {
282- // Same as CPython.
283- mp_raise_OSError (MP_EINVAL );
266+ return MP_EINVAL ;
284267 }
285268
286269 // Validate the host name (which might be a numeric IP string) to an IPv4 address first.
@@ -298,7 +281,7 @@ int common_hal_socketpool_socket_bind(socketpool_socket_obj_t *self,
298281 if (memcmp (ipv4 , zero_ipv4 , IPV4_LENGTH ) != 0 &&
299282 memcmp (ipv4 , self_ipv4 , IPV4_LENGTH ) != 0 ) {
300283 // Same as CPython.
301- mp_raise_OSError ( 99 ) ; // EADDRNOTAVAIL (sometimes 125!)
284+ return 99 ; // EADDRNOTAVAIL (sometimes 125!)
302285 }
303286 self -> bound = true;
304287 memcpy (self -> hostname , host , hostlen );
0 commit comments