for now I'm using:int connect(const String& address, int port) {    struct sockaddr_in servAddr;    struct hostent* host;            /* Structure containing host information */    /* open socket */    if((handle = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0)        return ERROR;    //TODO: gethostbyname is obsolete.    if((host = (struct hostent*) gethostbyname(address)) == 0)        return ERROR;    memset(&servAddr, 0, sizeof(servAddr));    servAddr.sin_family      = AF_INET;    servAddr.sin_addr.s_addr = inet_addr(inet_ntoa(*(struct in_addr*)(host -> h_addr_list[0])));    servAddr.sin_port        = htons(port);    if(::connect(handle, (struct sockaddr*) &servAddr, sizeof(servAddr)) < 0)        return ERROR;    return OK;    }this procedure but everytime I compile it I'm getting:socket.cpp:(.text+0x374): warning: gethostbyname is obsolescent, use getnameinfo() instead.getname info is still being confusing stuff for me. here is my try to implement it:struct sockaddr_in servAddr;struct hostent *host;        /* Structure containing host information *//* open socket */if ((handle = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0)    return ERROR;memset(&servAddr, 0, sizeof(servAddr));servAddr.sin_family      = AF_INET;servAddr.sin_addr.s_addr = inet_addr(address.ptr());servAddr.sin_port        = htons(port);char servInfo[NI_MAXSERV];if ( ( host = (hostent*) getnameinfo(                 (struct sockaddr *) &servAddr                 ,sizeof (struct sockaddr)                 ,address.ptr(), address.size()                 ,servInfo, NI_MAXSERV                 ,NI_NUMERICHOST | NI_NUMERICSERV )  ) == 0)    return ERROR;if (::connect(handle, (struct sockaddr *) &servAddr, sizeof(servAddr)) < 0)    return ERROR;-- yes this doesn't work :(Maybe I should use getaddrinfo instead? getaddrinfo(hostname, NULL, &hints, &res) - can I use it alike gethostbyname? but where is host actually here? hints?Working recode based on answer:int Socket::connect(const String& address, int port) {    struct sockaddr_in servAddr;    /* open socket */    if((handle = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0)        return ERROR;    //gethostbyname by getaddrinfo replacement    addrinfo hints = {sizeof(addrinfo)};    hints.ai_flags = AI_ALL;    hints.ai_family = PF_INET;    hints.ai_protocol = 4; //IPPROTO_IPV4    addrinfo* pResult = NULL;    int errcode = getaddrinfo(address, NULL, &hints, &pResult);    if(errcode != 0)        return ERROR;    memset(&servAddr, 0, sizeof(servAddr));    servAddr.sin_family      = AF_INET;    servAddr.sin_addr.s_addr = *((uint32_t*) & (((sockaddr_in*)pResult->ai_addr)->sin_addr));    servAddr.sin_port        = htons(port);    if(::connect(handle, (struct sockaddr*) &servAddr, sizeof(servAddr)) < 0)        return ERROR;    return OK;    }
Socket connect realization: gethostbyname or getnameinfo
c++
This works for me:int connect2(const CStringA& address, int port) {  struct sockaddr_in servAddr;  /* open socket */  SOCKET handle;  if((handle = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0)    return ERROR;  //gethostbyname by getaddrinfo replacement  ADDRINFO hints;  ZeroMemory(&hints, sizeof(hints));  hints.ai_flags = AI_ALL;  hints.ai_family = PF_INET;  hints.ai_protocol = IPPROTO_IPV4;  ADDRINFO* pResult = NULL;  int errcode = getaddrinfo((LPCSTR)address, NULL, &hints, &pResult);  if(errcode != 0)    return ERROR;  memset(&servAddr, 0, sizeof(servAddr));  servAddr.sin_family      = AF_INET;  servAddr.sin_addr.S_un.S_addr = *((ULONG*)&(((sockaddr_in*)pResult->ai_addr)->sin_addr));  servAddr.sin_port        = htons(port);  if(::connect(handle, (struct sockaddr*) &servAddr, sizeof(servAddr)) < 0)    return ERROR;  return OK;}