I'm trying to bind a client socket connection explicitly to my wlan but I just get a timeout. curl is working just fine so there should not be any firewall or routing issue.
import socket
def isOpen(ip, port, proto=socket.SOCK_STREAM):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(('192.168.2.15', 0))
print(s.getsockname())
s.settimeout(30)
try:
s.connect((ip, int(port)))
return True
except Exception as e:
print(e)
return False
finally:
s.close()
def test_wlan(): assert isOpen('1.1.1.1', 443)
poetry run pytest --no-header -s
=============== test session starts ===============
collected 1 item
tests/test_network.py ('192.168.2.15', 36031)
timed out
F
curl -v -4 --interface wlan https://1.1.1.1
...
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* old SSL session ID is stale, removing
< HTTP/2 200
...
Any idea what I need to do to make it work?