Make listen address and port configurable

Also add proper error handling when setting up the listening socket.