Socket connect realization: gethostbyname or getnameinfo
This works for me:

int connect2(const CStringA&amp; address, int port) {
  struct sockaddr_in servAddr;
  /* open socket */
  SOCKET handle;
  if((handle = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) &lt; 0)
    return ERROR;
  //gethostbyname by getaddrinfo replacement
  ADDRINFO hints;
  ZeroMemory(&amp;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, &amp;hints, &amp;pResult);
  if(errcode != 0)
    return ERROR;
  memset(&amp;servAddr, 0, sizeof(servAddr));
  servAddr.sin_family      = AF_INET;
  servAddr.sin_addr.S_un.S_addr = *((ULONG*)&amp;(((sockaddr_in*)pResult-&gt;ai_addr)-&gt;sin_addr));
  servAddr.sin_port        = htons(port);
  if(::connect(handle, (struct sockaddr*) &amp;servAddr, sizeof(servAddr)) &lt; 0)
    return ERROR;
  return OK;
}