//p_Url = my-staging.busch-jaeger.de
static int WebSocket_Get_ServerIp(char *p_Url, char *p_Ip)
{
assert(p_Url);
assert(p_Ip);
struct hostent *objHostInfo;
objHostInfo = gethostbyname(p_Url);
if(objHostInfo == NULL)
{
printf("Get Ip By Host Failed !!! \n");
return SN_ERROR;
}
sprintf(p_Ip,"%s", inet_ntoa(*((struct in_addr *)objHostInfo->h_addr)));
printf("==========HostName :%s , IP Address :%s\n",objHostInfo->h_name, p_Ip);
return SN_SUCCESS;
}
#include <stdio.h>
#include <stdlib.h>
#include <netdb.h>
#include <sys/socket.h>
#include <arpa/inet.h>
int main()
{
char sz_ip[32] = { 0 };
char *p_Url = "hxbucket.cmcqly.com";
struct hostent *objHostInfo;
objHostInfo = gethostbyname(p_Url);
if(objHostInfo == NULL)
{
printf("Get Ip By Host Failed !!! \n");
return -1;
}
sprintf(sz_ip,"%s", inet_ntoa(*((struct in_addr *)objHostInfo->h_addr)));
printf("==========HostName :%s , IP Address :%s\n",objHostInfo->h_name, sz_ip);
return 0;
}