getting hostname from ip (for all, cuz hostname can have dots too

This commit is contained in:
Dhanya Maliakal 2017-05-19 10:21:33 +02:00
parent e8e9e12302
commit 0e2d0f07e8

View File

@ -46,14 +46,13 @@ public:
char ip[MAX_STR_LENGTH] = "";
strcpy(ip, hostname_or_ip);
// convert hostname to ip
char* ptr = ConvertHostnameToIp (hostname_or_ip);
if (ptr == NULL)
return;
strcpy(ip, ptr);
// construct address
if (strchr (hostname_or_ip, '.') == NULL) {
// convert hostname to ip
char* ptr = ConvertHostnameToIp (hostname_or_ip);
if (ptr == NULL)
return;
strcpy(ip, ptr);
}
sprintf (serverAddress, "tcp://%s:%d", ip, portno);
// create context