Add functions to check the arguments' validation

Add function ip_check, file_check, port_check.
Fix function dir_check.
Fix the format of getopt.