Changed to print warnings for errors in shutting down.
Implemented getsockname(2).