+ break;
+ case 'c': /* set canonical host name resolution */
+ hint.ai_flags = hint.ai_flags | AI_CANONNAME;
+ break;
+ case 'd': /* set canonical host name resolution */
+ debug = 1;
+ break;
+ case 'p': /* set protocol value */
+ j = 0;
+ while ( (string = protocols[j]) != NULL ) {
+ if ( (strncmp(string, optarg, strlen(string)) == 0) ) {
+ hint.ai_protocol = protval[j];
+ break;
+ }
+ j++;
+ }
+ if (j>=2) {
+ printf("Wrong protocol, use 'tcp' or 'udp'\n\n");
+ usage();
+ }
+ break;
+ case 't': /* set socket type value */
+ j = 0;
+ while ( (string = socktype[j]) != NULL ) {
+ if ( (strncmp(string, optarg, strlen(string)) == 0) ) {
+ hint.ai_socktype = sockval[j];
+ break;
+ }
+ j++;
+ }
+ if (j>=2) {
+ printf("Wrong socket type, use 'dgram' or 'stream'\n\n");
+ usage();
+ }
+ break;
+ case 'v': /* set address type */
+ j = strtol(optarg, NULL, 10);
+ if (j == 4) {
+ hint.ai_family = PF_INET;
+ break;
+ }
+ if (j == 6) {
+ hint.ai_family = PF_INET6;
+ break;
+ }
+ printf("Wrong IP protocol version, use 4 o 6\n\n");
+ usage();