add -g option for debugging
handle connection reset by client