Skip to content

Commit 1f179b3

Browse files
committed
Adding socket and socketpool class attributes
1 parent 8e72b68 commit 1f179b3

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

shared-bindings/socket/__init__.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,21 @@ STATIC const mp_obj_type_t socket_type;
4949

5050
//| class socket:
5151
//|
52-
//| def __init__(self, family: int, type: int, proto: int) -> None:
52+
//| AF_INET = 2
53+
//| AF_INET6 = 10
54+
//| SOCK_STREAM = 1
55+
//| SOCK_DGRAM = 2
56+
//| SOCK_RAW = 3
57+
//| IPPROTO_TCP = 6
58+
//|
59+
//| def __init__(self, family: int = AF_INET, type: int = SOCK_STREAM, proto: int = IPPROTO_TCP) -> None:
5360
//| """Create a new socket
5461
//|
5562
//| :param int family: AF_INET or AF_INET6
5663
//| :param int type: SOCK_STREAM, SOCK_DGRAM or SOCK_RAW
5764
//| :param int proto: IPPROTO_TCP, IPPROTO_UDP or IPPROTO_RAW (ignored)"""
5865
//| ...
5966
//|
60-
//| AF_INET: int
61-
//| AF_INET6: int
62-
//| SOCK_STREAM: int
63-
//| SOCK_DGRAM: int
64-
//| SOCK_RAW: int
65-
//|
6667

6768
STATIC mp_obj_t socket_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
6869
mp_arg_check_num(n_args, kw_args, 0, 4, false);

shared-bindings/socketpool/SocketPool.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,22 @@ STATIC mp_obj_t socketpool_socketpool_make_new(const mp_obj_type_t *type, size_t
5757
return MP_OBJ_FROM_PTR(s);
5858
}
5959

60-
61-
//| def socket(self, family: int, type: int, proto: int) -> socketpool.Socket:
60+
//| AF_INET = 0
61+
//| AF_INET6 = 1
62+
//| SOCK_STREAM = 0
63+
//| SOCK_DGRAM = 1
64+
//| SOCK_RAW = 2
65+
//| IPPROTO_TCP = 6
66+
//|
67+
//| def socket(self, family: int = AF_INET, type: int = SOCK_STREAM, proto: int = IPPROTO_TCP) -> socketpool.Socket:
6268
//| """Create a new socket
6369
//|
6470
//| :param ~int family: AF_INET or AF_INET6
6571
//| :param ~int type: SOCK_STREAM, SOCK_DGRAM or SOCK_RAW
6672
//| :param ~int proto: IPPROTO_TCP, IPPROTO_UDP or IPPROTO_RAW (ignored)"""
6773
//| ...
6874
//|
75+
6976
STATIC mp_obj_t socketpool_socketpool_socket(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
7077
mp_arg_check_num(n_args, kw_args, 0, 5, false);
7178

0 commit comments

Comments
 (0)