ethereum/eth-go — pull request #53 by ebuchman (2014-09-29 02:14:38+00:00)
Title: allow stop listening

Allows one to toggle listening, and to quit the peer handler. This is especially useful if you'd like to restart the node from go - there was previously no way to exit the peerHandler, and hence no way to free the port from within process.

Note I use TCPListener instead of Listener so that Accept() will time out and I can catch quits. The go docs recommend against use of TCPListener. I suppose the alternative is to add the regular listener to the ethereum struct and just close that, which will cause Accept to return. But I didn't think about that until after doing this. Wouldn't be hard to do, but not sure which route is better.