Merge pull request #951 from rauls5382/service_names

Manually resolve well-known service names
pull/935/head
Abhishek Kumar 10 years ago
commit e7a523e910
  1. 15
      src/core/iomgr/resolve_address_posix.c

@ -101,6 +101,21 @@ grpc_resolved_addresses *grpc_blocking_resolve_address(
hints.ai_flags = AI_PASSIVE; /* for wildcard IP address */ hints.ai_flags = AI_PASSIVE; /* for wildcard IP address */
s = getaddrinfo(host, port, &hints, &result); s = getaddrinfo(host, port, &hints, &result);
if (s != 0) {
/* Retry if well-known service name is recognized */
char *svc[][2] = {
{"http", "80"},
{"https", "443"}
};
int i;
for (i = 0; i < (int)(sizeof(svc) / sizeof(svc[0])); i++) {
if (!strcmp(port, svc[i][0])) {
s = getaddrinfo(host, svc[i][1], &hints, &result);
break;
}
}
}
if (s != 0) { if (s != 0) {
gpr_log(GPR_ERROR, "getaddrinfo: %s", gai_strerror(s)); gpr_log(GPR_ERROR, "getaddrinfo: %s", gai_strerror(s));
goto done; goto done;

Loading…
Cancel
Save