I tell every developer buddy I have that they should get a pair of Fuck Off Headphones [0]. They need to be big enough that people can't try to say, "Oh, I didn't see you had headphones on".
I work from home now, and they work just as well for keeping my family at bay as they did for chatty coworkers when I had to be in an office.
[0] http://www.amazon.com/Logitech-Wireless-Gaming-Headset-Surro...