File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # test that socket.connect() has correct polling behaviour before, during and after
2+
3+ try :
4+ import usocket as socket , uselect as select
5+ except :
6+ import socket , select
7+
8+
9+ def test (peer_addr ):
10+ s = socket .socket ()
11+ poller = select .poll ()
12+ poller .register (s )
13+
14+ # test poll before connect
15+ # note: CPython can return POLLHUP, so use the IN|OUT mask
16+ p = poller .poll (0 )
17+ print (len (p ), p [0 ][- 1 ] & (select .POLLIN | select .POLLOUT ))
18+
19+ s .connect (peer_addr )
20+
21+ # test poll during connection
22+ print (len (poller .poll (0 )))
23+
24+ # test poll after connection is established
25+ p = poller .poll (1000 )
26+ print (len (p ), p [0 ][- 1 ])
27+
28+ s .close ()
29+
30+
31+ if __name__ == "__main__" :
32+ test (socket .getaddrinfo ('micropython.org' , 80 )[0 ][- 1 ])
Original file line number Diff line number Diff line change 1+ 1 4
2+ 1
3+ 1 4
You can’t perform that action at this time.
0 commit comments