move IP address and misc. helpers out from middle of TCPSocket code
close socket when stream finished, fire end event whenever __listen loop ceases. updates #310, for posix version at least