When the client closes its socket, on OSX it closes the server one as well, leading to an errno.ENOTCONN when trying to shut it down. Also use the unified socket-closing function to handle tinysocket bzr revid: xmo@openerp.com-20110616102624-vixxow6twsx7j84s