title: C++ WinSock Get Data From PHP Page?
body: <p>Hello I'm quite new to using <code>sockets</code> and am not that familiar with them yet, Basically all i am trying to do is pass a <code>string variable</code> to a <code>web address</code> (e.g. <code>www.example.com/index.php?Example=StringExample</code>) and then get a response, so for example it would return <code>"Test Example"</code> if <code>index.php</code> looked like this:</p>
  
  <pre><code>&lt;?php
  
  if($_GET['Example'] == "StringExample")
  {
      echo "Test Example";
  }
  
  ?&gt;
  </code></pre>
  
  <p>Here is what I've tried in c++:</p>
  
  <pre><code>struct sockaddr_in SocketAddress;
  hostent* addr = gethostbyname("www.example.com/index.php?Example=StringExample");
  int sizeofaddr = sizeof(addr);
  SocketAddress.sin_addr.s_addr = inet_addr(addr-&gt;h_name);
  SocketAddress.sin_port = htons(80);
  SocketAddress.sin_family = AF_INET; 
  
  SOCKET Connection = socket(AF_INET, SOCK_STREAM, NULL); 
  if (connect(Connection, (SOCKADDR*)&amp;addr, sizeofaddr) != 0) 
  {
      return 0; //Failed to Connect
  }
  
  char buffff[256];
  recv(Connection, buffff, sizeof(buffff), NULL);
  //"Test Example" now stored in    buffff
  </code></pre>
  
  <p>What am i doing wrong? </p>
  
  <p>Btw in my case i would not like to use any <code>libraries</code> like <code>boost</code> or anything like that. Thanks for the help :)</p>