While this is not strictly a security-related snippet, it might still be interesting curiosity for someone working on that field and having to deal with a hostile or just mad Wi-Fi Access Point (AP) which just keeps on dropping the connection.
In this scenario, there are no other more well behaving APs around, and one just want to stay online. Rejoining manually and ignoring the connection failure notifications is one way to go, but as the events occur too frequently, they can become a real bottleneck in the production process.
Hence a good solution is for the Mac OS X to build up a small bash script to keep on joining, as soon as the connection drops. Luckily Apple provides a built-in command to connect to a Wi-Fi AP with given SSID and password. Building a loop around that is also trivial.
while [ $op -eq 1 ]; do
xop=$( networksetup -setairportnetwork en0 SSID PASSWORD )
# you could check the return value here, but we just ignore
This would just keep on joining until killed. And what is funny, it actually solves the issue mostly, as the time gap between the connection dropped and re-established is quite small. Of course one would need to take into account the local network policies, as the AP might consider frequent rejoins as a hostile behaviour, depending on the reason of the connection being dropped (for that matter, check the output in xop variable).
But, for the curious minds, this is good learning point, and at least reminds about the powerful networksetup command to be used for this and many other manoeuvres.