- case 'b': {
- struct hostent *h = gethostbyname(optarg);
- if (!h)
- die(EXIT_FAILURE, "unknown host name `%s'", optarg);
- memcpy(&baddr, h->h_addr, sizeof(struct in_addr));
- } break;
- case 'p': {
- char *p;
- unsigned long i = strtoul(optarg, &p, 0);
- if (*p) {
- struct servent *s = getservbyname(optarg, "udp");
- if (!s)
- die(EXIT_FAILURE, "unknown service name `%s'", optarg);
- i = ntohs(s->s_port);
- }
- if (i >= 65536)
- die(EXIT_FAILURE, "bad port number %lu", i);
- port = i;
- } break;