title: Socket Error 10047
body: <p>So I am really stuck here, just trying to make a simple C program that gets the content of a webpage into a buffer, but I'm having some problems; consider the following:</p>
  
  <pre><code>WORD wVersionRequested;
  WSADATA wsaData;
  int err;
  
  wVersionRequested = MAKEWORD( 2, 2 );
  err = WSAStartup( wVersionRequested, &amp;wsaData );
  if(err != 0)
  {
      printf("could not find a usable winsock.dll");
      return NULL;
  }
  if(LOBYTE(wsaData.wVersion) != 2 || HIBYTE(wsaData.wVersion) != 2) 
  {
      printf("could not find a usable winsock.dll");
      WSACleanup();
      return NULL;
  }
  SOCKET sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
  struct sockaddr_in sa = { 0 };
  sa.sin_port = htons(port);
  sa.sin_addr.s_addr = inet_addr(ip);
  connect(sock, (struct sockaddr*)&amp;sa, sizeof(sa));
  </code></pre>
  
  <p>The variables <code>ip</code>, and <code>port</code>, are passed through from main. as you can see here:</p>
  
  <pre><code>readsite("http://www.pagetutor.com/html_tutor/index.html", "68.71.137.60", 80);
  </code></pre>
  
  <p>I get the error code "10047" from executing <code>printf("\n%d", GetLastError());</code> directly below the line <code>connect(sock, (struct sockaddr*)&amp;sa, sizeof(sa));</code> and this code according to microsoft means "Addresses in the specified family cannot be used with this socket" so I am completely at a lost on what to do from here.</p>