Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A small example of connecting to wpa_supplicant daemon control socket that is also used by wpa_cli with python
import os
import select
import socket
interface = "wlan1"
wpa_send_path = "/run/wpa_supplicant/"+interface
wpa_recv_path = "/tmp/wpa_ctrl_{pid}-{count}".format(pid=os.getpid(), count=1)
soc = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM, 0)
soc.bind(wpa_recv_path)
soc.connect(wpa_send_path)
print("> PING")
soc.send(b"PING")
print("<", soc.recv(4096).decode().strip())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment