0


I'm trying to find a way to run a script in python that "listens" to wifi connection status and will execute a certain function that I made when the computer gets connected to wifi.

The function will connect to a server socket and send some information to it.

Does anyone have any idea how to implement this?

Thanks!

Akshay Pratap Singh
  • 3,197
  • 1
  • 24
  • 33
Shawn
  • 11
  • 1
  • 5

1 Answers1

0

Checking the wifi connection status can be handled in a few ways (see here for some options). You can then poll that with a structure along the lines of:

while not done:
    if is_interface_up(interface):
       do_the_thing(interface)
    time.sleep(0.1)

If this is a more substantial application you might want to do this with an event driven architecture instead of a while loop---something along the lines of Twisted.

Community
  • 1
  • 1
6c1
  • 392
  • 2
  • 14