add getopt to handle options; support '-a addr' to specify the dest addr; added detailed error information to show when something goes wrong