OpenBazaar/OpenBazaar — pull request #1006 by benemorius (2014-11-11 22:12:01+00:00)
Title: reuse CryptoPeerConnection objects (too-many-files bug hotfix)

I'm proposing this as a hotfix for 0.3.1 since virtually everyone is getting the "too many files" crash. This should fix that crash until the network doubles in size, at least for people who don't have their maxfiles limit set unusually low.

Further fixing of this "too many files" bug will require fundamental changes in our networking code. This is probably about as good as we're going to get it without refactoring. I believe this was the last contributing factor I could find that was an actual bug. Beyond this, we're just doing it wrong, mostly by keeping open connections to the entire network.

Please test.

```
watch -n1 "echo -n 'in: '; netstat -ntup | grep "env/bin/pyt" | grep "192.168.8.88:12345" | wc -l; echo -n 'out: '; netstat -ntup | grep "env/bin/pyt" | egrep -v '192.168.8.88:12345|127.0.0.1' | wc -l; echo -n 'established: '; netstat -ntup | grep "env/bin/pyt" | egrep -v '192.168.8.88:12345|127.0.0.1' | grep ESTABLISHED | wc -l; echo -n 'open files: '; lsof -nc python 2>/dev/null | wc -l"
```